[racket] Lazy take is the identity?

From: John Clements (clements at brinckerhoff.org)
Date: Wed Jan 26 14:41:38 EST 2011

On Jan 26, 2011, at 4:29 AM, Casey Klein wrote:

> On Wed, Jan 26, 2011 at 1:27 AM, John Clements
> <clements at brinckerhoff.org> wrote:
>> I would expect this program to signal an error:
>> #lang lazy
>> (define zeros (cons 0 zeros))
>> (define should-be-error (list-ref (take 15 zeros) 1324))
>> ... but instead should-be-error is bound to zero.  How can I take the 1000th element of a list with only 15 elements?  I'm tempted to make snide comments about laziness, but I'm sure it'll backfire when it turns out that somehow that's the right answer after all.
>> Bug report?
> Sure enough:
> http://bugs.racket-lang.org/query/?cmd=view&pr=11458

Correct me if I'm wrong, but this appears to be a different issue.  The question here is not laziness, but the length of the resulting list.  Here's another example:

#lang lazy

(define zeros (cons 0 zeros))

(define lazy-list-of-length-one (take 1 zeros))

(define should-be-null (rest lazy-list-of-length-one))


Welcome to DrRacket, version [3m].
Language: lazy [custom]; memory limit: 256 MB.
> (! should-be-null)
'(0 . #<promise:...llects/lazy/lazy.rkt:588:41>)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4669 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20110126/68832c22/attachment.p7s>

Posted on the users mailing list.