<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/12/69ebad4a16ce944d2f01e9878f67739b"
  from="sebastien FURIC &lt;sebastien.furic@t...&gt;"
  author="sebastien FURIC"
  date="2002-12-16T09:25:12"
  subject="[Caml-list] Re: A similar small problem"
  prev="2002/12/c6cf5d6a698ddeb08791e29a39e73382"
  next="2002/12/19ad47102b6603fa1fed04a80f1f62b7"
  prev-thread="2002/12/c1c05f314ad9a12a76fe27ff77f36cd8"
  next-thread="2002/12/19ad47102b6603fa1fed04a80f1f62b7"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Re: A similar small problem">
<msg 
  url="2002/12/69ebad4a16ce944d2f01e9878f67739b"
  from="sebastien FURIC &lt;sebastien.furic@t...&gt;"
  author="sebastien FURIC"
  date="2002-12-16T09:25:12"
  subject="[Caml-list] Re: A similar small problem">
</msg>
</thread>

<contents>


Klaus Benecke a écrit :
&gt; 
&gt; Thank you very much for your comments,
&gt; I installed OCAML 3.01 and the mentioned problems disappeared,
&gt; but a similar problem remains:
&gt; 
&gt; let rec inclu_l=fun
&gt;  [] l -&gt; true
&gt;  | (n::ns) l -&gt; mem n l &amp; inclu_l ns l;;
&gt; 
&gt;  File "C:/OTTO/CAMLquellen/XML2002/test.ml", line 3, characters
&gt; 1-2:
&gt; Syntax error
&gt; Can you help me once more?
&gt; Mit freundlichen Gruessen
&gt; Klaus Benecke
&gt; e-mail: benecke@iws.cs.uni-magdeburg.de
&gt; home-page: http://theo.cs.uni-magdeburg.de/benecke.html
 
 "fun patt1 patt2 ... pattn -&gt;" could be view as a macro for:
 "function patt1 -&gt; function patt2 -&gt; ... function pattn -&gt;"
 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
  | [], _ -&gt; true
  | n :: ns', _ -&gt; mem n l &amp;&amp; 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
  | [] -&gt; true
  | n :: ns' -&gt; mem n l &amp;&amp; inclu_l l ns'

 Or, (syntactically) better:

 let rec inclu_l l = function
  | [] -&gt; true
  | n :: ns -&gt; mem n l &amp;&amp; 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

</contents>

</message>

