caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Johann Spies <jhspies@adept.co.za>
To: caml-list@inria.fr
Subject: [Caml-list] Why do I get a syntax error?
Date: Sat, 22 Dec 2001 23:43:33 +0200	[thread overview]
Message-ID: <20011222234333.A11911@adept.co.za> (raw)

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


             reply	other threads:[~2001-12-22 21:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-22 21:43 Johann Spies [this message]
     [not found] <a02vg7$qf2$1@qrnik.zagroda>
2001-12-23 15:47 ` Marcin 'Qrczak' Kowalczyk
2001-12-23 20:58   ` Johann Spies

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011222234333.A11911@adept.co.za \
    --to=jhspies@adept.co.za \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).