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
How important are circular lists/recursive objects?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-04-02 (23:55)
From: Brian Hurt <bhurt@s...>
Subject: How important are circular lists/recursive objects?

In Ocaml you have some ability to define recursive data structures.  The 
classic example of this is the circular list:

let rec example = 1 :: 2 :: example;;

There are obvious limitations to this sort of trick:

# let rec example = List.map (fun x -> x + 1) (1 :: 2 :: example);;
This kind of expression is not allowed as right-hand side of `let rec'

The question is: if this behavior was completely outlawed, and either you 
couldn't build up circular lists/recursive data structures of this type at 
all, or had to call special functions (List.circularize, say), to create 
them, would this be a signifigant problem?  Does anyone actually use this 
construct, and if so, for what?