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

Re: [Scheme-reports] must list-copy handle cycles?



On Tue, Jul 3, 2012 at 5:28 AM, Per Bothner <per@x> wrote:
> The text for list-copy seems to suggest that it must handle
> cyclic lists, but it doesn't explicitly say so.
>
> The Common Lisp Hyperspec says of copy-list:
>    The consequences are undefined if list is a circular list.
>
> If list-copy must handle cycles, what's a good algorithm?

Hair and tortoise works here - just use normal list-copy,
but if they ever meet up revert to the more expensive
algorithm.

For handling cycles in equal? you can refer to Clinger's
srfi-85 or:

  https://www.cs.indiana.edu/~adamsmd/papers/efficient_equality/

-- 
Alex

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports