From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id BE6517FADC for ; Wed, 5 Nov 2014 13:24:56 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of pierrickcouderc@gmail.com) identity=pra; client-ip=209.85.215.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierrickcouderc@gmail.com"; x-sender="pierrickcouderc@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of pierrickcouderc@gmail.com designates 209.85.215.43 as permitted sender) identity=mailfrom; client-ip=209.85.215.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierrickcouderc@gmail.com"; x-sender="pierrickcouderc@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f43.google.com) identity=helo; client-ip=209.85.215.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierrickcouderc@gmail.com"; x-sender="postmaster@mail-la0-f43.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al4BADgWWlTRVdcrlGdsb2JhbABcgkiBGl2DArpqjmuBb4dNAoEPBxYBAQEBAREBAQEBBwsLCRIwhAIBAQEDARIRBBkBGxILAQMMBgULBgMBAgENHQICIgERAQUBCgoIBhMICgkHiAkBAwkJDaZ7PTGLM4FzgxGJIQoZJwMKaIVFAQEBAQEBAQEBAQEBAQEBAQEBARMBBQ6QcQ0EBwaCcYFUBYUdBZFQhxyBMT2QW4IOGCmDF4IcPC+CSwEBAQ X-IPAS-Result: Al4BADgWWlTRVdcrlGdsb2JhbABcgkiBGl2DArpqjmuBb4dNAoEPBxYBAQEBAREBAQEBBwsLCRIwhAIBAQEDARIRBBkBGxILAQMMBgULBgMBAgENHQICIgERAQUBCgoIBhMICgkHiAkBAwkJDaZ7PTGLM4FzgxGJIQoZJwMKaIVFAQEBAQEBAQEBAQEBAQEBAQEBARMBBQ6QcQ0EBwaCcYFUBYUdBZFQhxyBMT2QW4IOGCmDF4IcPC+CSwEBAQ X-IronPort-AV: E=Sophos;i="5.07,319,1413237600"; d="scan'208";a="86428420" Received: from mail-la0-f43.google.com ([209.85.215.43]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Nov 2014 13:24:55 +0100 Received: by mail-la0-f43.google.com with SMTP id ge10so562131lab.30 for ; Wed, 05 Nov 2014 04:24:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=RqKzROMpsE8cre6a1axx3vz2j7l/kmJAZe9S0Z4RYSU=; b=hzJq0cLveEsuzK8D/IJL9WfChURmUDM65tgUphCXWDNf//xP0pv5WU/bzqFlI+J0B4 O/TfAdI8h9rUQ9MkREri1842ai7z5m/sx/bWzMBR8rKLMzIGnBITBVpZqGOSbDh59p+m cEw1GrU1tKTa1Y3etSJ4fJAiYijT47FHidudHdFyUmqqBSTvPGHxjlBUZpcPYHAdeZvI 3TwL2LJXDNnXOTAx0wpX18rpEJMANECgxrTVO11zGGp9JL430dJTVDBMRBFzdJMCTF22 B7A5dklcsEjSyJI/QRZ0DiWJG4VPkReq/rThFY95+XS36ngRy3/VTCznC9J5eUO7rSHJ Ve+Q== X-Received: by 10.152.42.212 with SMTP id q20mr20798744lal.10.1415190295146; Wed, 05 Nov 2014 04:24:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.159.134 with HTTP; Wed, 5 Nov 2014 04:24:34 -0800 (PST) In-Reply-To: <545A14D5.1090907@inria.fr> References: <545A14BE.5080308@inria.fr> <545A14D5.1090907@inria.fr> From: Pierrick Couderc Date: Wed, 5 Nov 2014 13:24:34 +0100 Message-ID: To: Francois Berenger Cc: "caml >> OCaml List" Content-Type: multipart/alternative; boundary=001a11c365fed4f68805071baaf5 Subject: Re: [Caml-list] what is here the syntax error --001a11c365fed4f68805071baaf5 Content-Type: text/plain; charset=UTF-8 > > Your last line is wrong: > [_] -> last [_::t] ;; > > try to replace it with: > x :: xs -> last xs ;; Actually, that's the syntax of the pattern mathing that is wrong (but this would also raise en error) : each case should begin with a '|' (the pipe is optional for the first line). i.e. : match list with [] -> None | [x] -> Some x | _ :: xs -> last xs Pierrick 2014-11-05 13:15 GMT+01:00 Francois Berenger : > > > > -------- Forwarded Message -------- > Subject: Re: [Caml-list] what is here the syntax error > Date: Wed, 05 Nov 2014 13:14:54 +0100 > From: Francois Berenger > To: Roelof Wobben > > On 11/05/2014 12:45 PM, Roelof Wobben wrote: > >> Hello, >> >> I know this question must be asked on the beginners list but I still did >> not get approved after I left the list. >> >> I try again to learn Ocaml and Im stuck at exercise 1 of the 99 ocaml >> problems. >> >> Here is my solution : >> >> let rec last list = >> match list with >> [] -> None >> [x] -> Some x >> [_] -> last [_::t] ;; >> > > Your last line is wrong: > [_] -> last [_::t] ;; > > try to replace it with: > x :: xs -> last xs ;; > > But now I see a syntax error on the [x] part. >> >> Can anyone explain to me what I did wrong ? >> >> Roelof >> >> >> > -- > Regards, > Francois. > > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- Pierrick COUDERC *PhD Student at OCamlPro / Ensta* --001a11c365fed4f68805071baaf5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Your last line is wrong:
[_]=C2=A0 =C2=A0-> = last [_::t] ;;

try to replace it with:
x :: xs -> last xs ;;

Actually, that's the syntax of the pattern mathing that is wrong (but = this would also raise en error) : each case should begin with a '|'= (the pipe is optional for the first line).
i.e. :
matc= h list with=C2=A0
=C2=A0 =C2=A0 [] -> None
=C2=A0 | = [x] -> Some x
=C2=A0 | _ :: xs -> last xs

Pierrick

2014-11-05 13:15 GMT+01:00 Francois Berenger &= lt;francois= .berenger@inria.fr>:



-------- Forwarded Message --------
Subject: Re: [Caml-list] what is here the syntax error
Date: Wed, 05 Nov 2014 13:14:54 +0100
From: Francois Berenger <francois.berenger@inria.fr>
To: Roelof Wobben <r.wobben@home.nl>

On 11/05/2014 12:45 PM, Roelof Wobben wrote:
Hello,

I know this question must be asked on the beginners list but I still did
not get approved after I left the list.

I try again to learn Ocaml and Im stuck at exercise 1 of the 99 ocaml
problems.

Here is my solution :

let rec last list =3D
=C2=A0 =C2=A0 match list with
=C2=A0 =C2=A0 =C2=A0 []=C2=A0 -> None
=C2=A0 =C2=A0 =C2=A0 [x] -> Some x
=C2=A0 =C2=A0 =C2=A0 [_]=C2=A0 =C2=A0-> last [_::t] ;;

Your last line is wrong:
[_]=C2=A0 =C2=A0-> last [_::t] ;;

try to replace it with:
x :: xs -> last xs ;;

But now I see a syntax error on the [x] part.

Can anyone explain to me what I did wrong ?

Roelof



--
Regards,
Francois.



--
=
Pierrick COUDERC
=

PhD Student at OCamlPro / Ensta
--001a11c365fed4f68805071baaf5--