English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2003-11-18 (00:18)
From: chris.danx <chris.danx@n...>
Subject: [Caml-list] Records: syntax error...

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?


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