caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "sebastien FURIC" <sebastien.furic@tni-valiosys.com>
To: benecke@iws.cs.uni-magdeburg.de, caml-list@inria.fr
Cc: Sven Luther <luther@dpt-info.u-strasbg.fr>
Subject: [Caml-list] Re: A similar small problem
Date: Mon, 16 Dec 2002 10:24:07 +0100	[thread overview]
Message-ID: <3DFD9BB7.34E90061@tni.fr> (raw)
In-Reply-To: <200212160855.gBG8tvL14522@iws.cs.uni-magdeburg.de>



Klaus Benecke a écrit :
> 
> Thank you very much for your comments,
> I installed OCAML 3.01 and the mentioned problems disappeared,
> but a similar problem remains:
> 
> let rec inclu_l=fun
>  [] l -> true
>  | (n::ns) l -> mem n l & inclu_l ns l;;
> 
>  File "C:/OTTO/CAMLquellen/XML2002/test.ml", line 3, characters
> 1-2:
> Syntax error
> Can you help me once more?
> Mit freundlichen Gruessen
> Klaus Benecke
> e-mail: benecke@iws.cs.uni-magdeburg.de
> home-page: http://theo.cs.uni-magdeburg.de/benecke.html
 
 "fun patt1 patt2 ... pattn ->" could be view as a macro for:
 "function patt1 -> function patt2 -> ... function pattn ->"
 so your program is not syntactically valid. You have to use "match ...
with" if you want to match against more than one pattern:

 let rec inclu_l ns l = match ns, l with
  | [], _ -> true
  | n :: ns', _ -> mem n l && inclu_l l ns'

 However, since you don't have to match "l" against anything (hence
wildcards), you can simply write:

 let rec inclu_l ns l = match ns with
  | [] -> true
  | n :: ns' -> mem n l && inclu_l l ns'

 Or, (syntactically) better:

 let rec inclu_l l = function
  | [] -> true
  | n :: ns -> mem n l && inclu_l l ns

 by exanching "l" with the matched list (arguments that do not need to
be matched are often placed at first positions).

 Cheers,

 Sebastien.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


           reply	other threads:[~2002-12-16  9:25 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <200212160855.gBG8tvL14522@iws.cs.uni-magdeburg.de>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3DFD9BB7.34E90061@tni.fr \
    --to=sebastien.furic@tni-valiosys.com \
    --cc=benecke@iws.cs.uni-magdeburg.de \
    --cc=caml-list@inria.fr \
    --cc=luther@dpt-info.u-strasbg.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).