Re: Page 76 of OCaml by John Whitington ???

"Oliver Bandel [email protected] [ocaml_beginners]" <[email protected]> Thu, 24 Mar 2016 17:45:11 +0100
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <20160324174511.Horde.Bxe2E5Ydi1FGYlgPgE4g9LJ@webmail.in-berlin.de>
Try with parantheses:

append (Cons(5, Nil)) Nil ;;



Ciao,
    Oliver

Zitat von "Douglas Lewit [email protected] [ocaml_beginners]"  
<[email protected]> (Thu, 24 Mar 2016 11:32:30 -0500)

> Good morning,
>
> I'm working on something on page 76 of "OCaml From the Very Beginning" by
> John Whitington.  This page is part of the Chapter on creating user-defined
> types.  I'm trying to use a function of his at the top of the page in the
> utop interface, but Ocaml doesn't like what I'm typing into utop.  Could
> someone please tell me what I'm doing wrong.  The functions are:
>
> *type 'a sequence = Nil | Cons of 'a * 'a sequence ;;*
>
> *let rec append a b = *
> *match a with *
> *Nil -> b*
> *| Cons (h, t) -> Cons( h, append t b ) ;;*
>
> So I'm typing in utop
>
> append Cons(5, Nil) Nil ;;
>
> This returns an error!
>
> I also tried
>
> append Cons(5, Nil) Cons(6, Nil) ;;
>
> but again this returned an error.  Could someone please explain this.  I
> think the purpose of this type is to simulate the builtin list type.  It's
> a great example IF I COULD GET THIS TO WORK!  Thanks for the guidance.