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] let rec
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-01-15 (20:02)
From: Max Kirillov <max630@m...>
Subject: Re: [Caml-list] let rec
On Wed, Jan 15, 2003 at 10:15:48PM +0300, Vitaly Lugovsky wrote:
VL>  It's not so funny. Why I can't write it using let rec:
VL>     let rec f (il,al,ht) =
VL>       let il2 = Array.make (n2+1) Lnil in
VL>       acopy il il2;
VL>       Array.iteri (fun i x -> il2.(all.(i)) <- x) al;
VL>       xprs (il2,anul,ht)
VL>     and xprs =
VL>       (Hashtbl.replace ht name (CTfun(f));
VL>        compile_exprs env2 exprs) in
VL>     f

You may use lazy things:

>     let rec f (il,al,ht) =
>       let il2 = Array.make (n2+1) Lnil in
>       acopy il il2;
>       Array.iteri (fun i x -> il2.(all.(i)) <- x) al;
>       (Lazy.force xprs) (il2,anul,ht)
>     and xprs =
>       lazy ((Hashtbl.replace ht name (CTfun(f));
>		compile_exprs env2 exprs)) in
>     (*optional*) ignore(Lazy.force xprs);
>     f

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