[Scheme-reports] must list-copy handle cycles? Per Bothner (02 Jul 2012 20:31 UTC)
Re: [Scheme-reports] must list-copy handle cycles? Alex Shinn (02 Jul 2012 20:42 UTC)
Re: [Scheme-reports] must list-copy handle cycles? John Cowan (02 Jul 2012 21:52 UTC)

Re: [Scheme-reports] must list-copy handle cycles? Alex Shinn 02 Jul 2012 20:42 UTC

On Tue, Jul 3, 2012 at 5:28 AM, Per Bothner <per@bothner.com> 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@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports