chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Cyclic lists and the Interpreter


From: Jim Ursetto
Subject: Re: [Chicken-users] Cyclic lists and the Interpreter
Date: Tue, 8 Apr 2008 11:56:16 -0600

On 4/8/08, Graham Fawcett <address@hidden> wrote:
> On Mon, Apr 7, 2008 at 3:24 PM, Alex Rozenshteyn <address@hidden>
> > 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]