Browse thread
[Caml-list] Recursive lists
[
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: | -- (:) |
| From: | Alex Baretta <alex@b...> |
| Subject: | Re: [Caml-list] Recursive lists |
William Lovas wrote:
> On Sun, Oct 10, 2004 at 07:44:25PM -0500, Brian Hurt wrote:
>>
>>Note: I haven't tested the above functions, but they give you the idea of
>>how to handle circular lists.
>
>
> ... and this isn't it :) I think Alex was more on the right track with the
> idea of maintaining a list of tails...
>
> cheers,
> William
Exactly: physical equality of nodes has nothing to do with the physical
equality of lists. Ocaml allows sharing, so the same object can appear
in more than one position even in an ordinary list or in any other Ocaml
datastructure.
e.g.
let l =
let x = <...> in
let y = <...> in
[x; y; y; x; ...]
Here the first and fourth element are physically equal, as well as the
second and third.
Alex
-------------------
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