[racket] circular lists are not lists or sequences
On 12/10/12 10:14 AM, Matthew Flatt wrote:
> We did change `in-list' to add a `list?' guard, so the behavior is as
> intended. Maybe we need a new `in-' sequence constructor that works as
> long as pairs appear for as far as you demand sequence elements?
Yes, an `in-pairs' seems right to me. I can submit a pull request if
that design is OK.
(I guess I'm a little surprised that `list?' returns false for a
circular list since a circular list never falsifies the list definition
given in the docs.)
David
> At Mon, 03 Dec 2012 18:12:51 -0500, David Van Horn wrote:
>> I have some code that's been broken somewhere between 5.1.1 and git
>> HEAD. The issue seems to be either that circular lists no longer are
>> considered lists by `list?', or `in-list' has added a `list?' check (and
>> circular lists were never `list?').
>>
>> In any case, these are the kinds of things I would expect to work, but
>> don't. Is this a bug?
>>
>> > (for/first ([y (shared ((x (cons 1 x))) x)]) y)
>> for: expected a sequence for y, got something else: #0='(1 . #0#)
>> context...:
>>
>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/for.rkt:451:2:
>> make-sequence
>>
>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/misc.rkt:87:7
>>
>> > (for/first ([y (in-list (shared ((x (cons 1 x))) x))]) y)
>> in-list: contract violation
>> expected: list?
>> given: #0='(1 . #0#)
>> context...:
>>
>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/for.rkt:551:2:
>> in-list
>>
>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/misc.rkt:87:7
>>
>> Thanks,
>> David
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users