On 4/8/08, Graham Fawcett <[EMAIL PROTECTED]> wrote:
> On Mon, Apr 7, 2008 at 3:24 PM, Alex Rozenshteyn <[EMAIL PROTECTED]>
> > 2) Is the interpreter supposed to freeze if length is passed a cyclic
> list?

> Yes, it's correct. See length and length+ in SRFI-1:
> http://srfi.schemers.org/srfi-1/srfi-1.html#Miscellaneous
> length+ will give you sane behaviour with cyclic lists.

For background, you can find some information on the design of length+ at:
http://srfi.schemers.org/srfi-1/mail-archive/msg00038.html

Of course, length+ returns #f for circular lists.  If you want a
count of "distinct elements", a procedure using the tortoise and hare
algorithm is available in the same thread:

http://srfi.schemers.org/srfi-1/mail-archive/msg00096.html

The question of whether "how many elements are in a circular list" is
well-defined is also discussed.

Jim


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to