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