Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Why do I get a syntax error?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Johann Spies <jhspies@a...>
Subject: [Caml-list] Why do I get a syntax error?
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