List Info

Thread: "ocaml_beginners"::[] Pattern matching of type constructors with arguments




"ocaml_beginners"::[] Pattern matching of type constructors with arguments
user name
2006-09-15 23:31:25
On Fri, 15 Sep 2006, doug_arro wrote:

> Why am I getting an error when applying the extract_odd
this way in
> the top level?
>
> ==============================
> # Acons(1, (Bcons(2, Acons(3, Bcons(4,Nil)))));;
> - : (int, int) list2 = Acons (1, Bcons (2, Acons (3,
Bcons (4,
> Nil))))
> # extract_odd Acons(1, (Bcons(2, Acons(3,
Bcons(4,Nil)))));;
> Characters 0-11:
>   extract_odd Acons(1, (Bcons(2, Acons(3,
Bcons(4,Nil)))));;
>   ^^^^^^^^^^^
> This function is applied to too many arguments,
> maybe you forgot a `;'
> #

The thing is that you must add a pair of parentheses.
You meant:
  extract_odd (Acons(1, (Bcons(2, Acons(3,
Bcons(4,Nil))))));;

I tend to put more spaces:
  extract_odd (Acons (1, (Bcons (2, Acons (3, Bcons (4,
Nil))))));;


Martin

--
Martin Jambon, PhD
http://martin.jambon.fre
e.fr


Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    ht
tp://groups.yahoo.com/group/ocaml_beginners/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:ocaml_beginners-digest@yahoogroups.com 
    mailto:ocaml_beginners-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



[1]

about | contact  Other archives ( Real Estate discussion Medical topics )