caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Diego Olivier Fernandez Pons <Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Not allowed as right-hand side of 'let rec'
Date: Thu, 8 Aug 2002 14:08:58 +0200 (DST)	[thread overview]
Message-ID: <Pine.A32.3.95.1020808134544.51718E-100000@ibm1.cicrp.jussieu.fr> (raw)

    Bonjour,

Je suis entrain de coder des Skip Lists (William Pugh 1990, 1994) qui
est une structure de données populaire outre-Atlantique et consiste en
une liste circulaire chaînée dont tout élément de hauteur h pointe en
outre vers son 2^k successeur avec k < h (le tout à la sauce random
américaine)

M'inspirant des listes circulaires chaînées (Cousineau et Mauny,
Pottier) j'ai écrit :

type 'a cell = { next : 'a cell array ; content : 'a }
type 'a skipList = int * 'a cell

Random.self_init ();;
let max_height = 10;;

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', me forçant à me rabattre sur un type
union

 type 'a cell = E | C of 'a cell array * 'a

Pourquoi son comportement est-il différent du cas des listes
circulaires simplement chaînées ? 

 type 'a cell = { next : 'a cell ; content ; 'a }

        Diego Olivier

note : si l'on pouvait avoir un affichage un peu plus réduit pour les
enregistrements qui pointent sur eux-mêmes ?

-------------------
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


             reply	other threads:[~2002-08-08 12:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-08 12:08 Diego Olivier Fernandez Pons [this message]
2002-08-08 12:56 ` Michel Quercia
2002-08-08 13:30   ` Alain Frisch
2002-08-09  8:48 Diego Olivier Fernandez Pons

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=Pine.A32.3.95.1020808134544.51718E-100000@ibm1.cicrp.jussieu.fr \
    --to=diego-olivier.fernandez-pons@cicrp.jussieu.fr \
    --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).