Browse thread
[Caml-list] Not allowed as right-hand side of 'let rec'
-
Diego Olivier Fernandez Pons
- Michel Quercia
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2002-08-08 (12:58) |
From: | Michel Quercia <michel.quercia@p...> |
Subject: | Re: [Caml-list] Not allowed as right-hand side of 'let rec' |
Le Thu, 8 Aug 2002 14:08:58 +0200 (DST) Diego Olivier Fernandez Pons <Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr> écrivit : > Je suis entrain de coder des Skip Lists ... > ... > let rec single = function x -> > let h = Random.int max_height in > let rec s = { next = Array.make h s ; next = x } > in (1, s) > > Le compilateur répond : This kind of expression is not allowed as > right-hand side of 'let rec' Car s est défini en fonction de lui-même par un appel de fonction : s = f(s) et le compilateur ne sait pas calculer automatiquement un point fixe de f. Ceci devrait marcher : let single = function x -> let h = Random.int max_height in let dummy = {next = [||]; content = x} in let s = { next = Array.make h dummy ; content = x } in Array.fill s.next 0 h s; (1, s) > note : si l'on pouvait avoir un affichage un peu plus réduit pour les > enregistrements qui pointent sur eux-mêmes ? Vous pouvez écrire une fonction d'impression ad-hoc et signaler au toplevel de l'utiliser via la directive install_printer. Cordialement, -- Michel Quercia 23 rue de Montchapet, 21000 Dijon http://michel.quercia.free.fr (maths) http://pauillac.inria.fr/~quercia (informatique) mailto:michel.quercia@prepas.org ------------------- 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