Page 76 of OCaml by John Whitington ???
"Douglas Lewit [email protected] [ocaml_beginners]" <[email protected]> Thu, 24 Mar 2016 11:32:30 -0500
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <CAM0XMJT6T=5gNQGgrOn2iAwVicguYwCW-SVrxBasxUb=LCx0NA@mail.gmail.com> |
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.