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: | Keith Wansbrough <Keith.Wansbrough@c...> |
| Subject: | Re: [Caml-list] Recursive lists |
> On Fri, 8 Oct 2004, Keith Wansbrough wrote:
[..]
> > How could they do this? It's just a list; there's nothing special
> > about it, except that it has no end.
>
> You can detect circular lists in O(N) thusly:
>
> let is_circular lst =
Yes, of course (and this is quite neat - I knew there was a
reasonable-space algorithm but couldn't recall it off the top of my
head). But this is hardly something you want built into List.map and
List.fold_{left,right}. (as others have pointed out)
--KW 8-)
-------------------
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