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

Re: LIST-LENGTH & circular lists

This page is part of the web mail archives of SRFI 1 from before July 7th, 2015. The new archives for SRFI 1 contain all messages, not just those from before July 7th, 2015.

At 4:13 PM -0500 2/18/99, Olin Shivers wrote:
>   From: Doug Currie <e@xxxxxxxxxxx>
>   One thing I have found useful is a version of list-length that terminates
>   on circular-lists, perhaps returning #f or 0 (or -N) for circular lists. It
>   kills two birds with one stone, and isn't much harder to implement than
>   circular-list?.
>We could extend LIST-LENGTH to return #F on circular lists.
>This does have the effect of screwing up type inference on LIST-LENGTH -- you
>can no longer conclude that it returns a fixnum.

If we accept Olin's proposition that "Everything is a list (Or: When you've
got a hammer...)" then everything should have a list length. So, I ammend
my suggestion above to say: Extend list-length so it terminates on
circular-lists, returning 0 for anything which is a circular-list (isn't a
proper-list or a dotted-list).