Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Records: syntax error...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: chris.danx <chris.danx@n...>
Subject: [Caml-list] Records: syntax error...
Hi,

I'm working my way through the ocaml book, and came across one exercise 
I can't get to work (sort of).  The exercise asked to define insert over 
the following type

type 'a dList =
   {l: 'a list; compare : 'a -> 'a -> bool; in_order : bool};;

I can get it to work with code similar to the solution, but since I had 
defined a merge function in the same file I decided to try using pattern 
matching on the record...


let insert item dl =
   match dl with
       {l = _; compare = _; in_order = true}  ->
               {merge dl.compare (dl.l, [item]), dl.compare, true}
     | {l = _; compare = _; in_order = false} ->
               {item::dl.l, dl.compare, false};;

but ocaml complains of a syntax error at dl.compare.  What did I do wrong?



Thanks,
Chris

-------------------
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