Re: LIST-LENGTH & circular lists
Doug Currie 19 Feb 1999 17:26 UTC
At 4:13 PM -0500 2/18/99, Olin Shivers wrote:
> From: Doug Currie <xxxxxx@flavors.com>
> 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).
e