caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Why do I get a syntax error?
@ 2001-12-22 21:43 Johann Spies
  0 siblings, 0 replies; 3+ messages in thread
From: Johann Spies @ 2001-12-22 21:43 UTC (permalink / raw)
  To: caml-list

I want to write a function which I can use to determine the
maximum length of a field in a database query so I want to build
a list of fieldnames and their lengths.  

I found it a lot more difficult to build such a list
than would be the case in python which I know better.

I am trying to figure out how ocaml would handle this but got
stuck with the following code. The compiler complains about a
syntax error in the line after the last line of code.
I apologize if it a stupid question, but I can not figure out
why.

-------------------------------------------------------------
let lys1 = ["a";"b";"c"]

type rek = { naam : string; lengte : int }

let rec bourekordlys lys nuwelys = 
  match lys with 
      [] -> nuwelys
    | h::t -> let rekord = {naam = h; lengte = 0}  in
              let l = List.append nuwelys [rekord] in 
              bourekordlys t l;;
   
let l = [];;

let ll = bourekordlys lys1 l in
  let lm = [] in
  let rec veranderde_lys ll lm =  
    match ll with   
      [] -> lm
     | h::t ->  let n = h.naam in 
                let lg = h.lengte + 5 in 
                let lz = List.append lm [{naam=n;lengte=lg}];
                  veranderde_lys t lz
---------------------------------------------------------

What is wrong here?

Johann
-- 
J.H. Spies - Tel. 021-982 2694 / 082 782 0336 / 021-808 4036(w)  
             Posbus 4668, Tygervallei 7536
     "And we know that all things work together for good to 
      them that love God, to them who are the called  
      according to his purpose."            
                                   Romans 8:28 
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 3+ messages in thread
[parent not found: <a02vg7$qf2$1@qrnik.zagroda>]

end of thread, other threads:[~2001-12-24  6:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-22 21:43 [Caml-list] Why do I get a syntax error? Johann Spies
     [not found] <a02vg7$qf2$1@qrnik.zagroda>
2001-12-23 15:47 ` Marcin 'Qrczak' Kowalczyk
2001-12-23 20:58   ` Johann Spies

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).