[racket] Lazy take is the identity?

From: Caner Derici (cderici at cs.bilgi.edu.tr)
Date: Wed Jan 26 06:06:11 EST 2011

On  5.0.99.6;

#lang lazy

(define ones (cons 1 ones))
(define ints (cons 1 (map + ints ones)))

(+ (list-ref (take 15 ints) 1234)) 2) produces 1237

'take' doesn't produce a proper list (which has a 'null' in the end),
instead it produces a list with an element and a promise. When another
function needs to go on with the rest, it sees that promise and can
continue with that., instead of seeing a 'null' and produce an error.
That's a bug I think.

-- caner

p.s. With the same program, I got an error on 5.0.1


On 01/26/2011 10:40 AM, Mark Engelberg wrote:
> I get an error in 5.0.2, rather than 0.
>
> --Mark
>
> P.S. I was surprised to see that list-ref in #lang lazy takes the args
> in opposite order than in #lang racket (which takes the list first).
>
> On Tue, Jan 25, 2011 at 11:27 PM, John Clements
> <clements at brinckerhoff.org <mailto: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?
>
>     John
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20110126/d9ec018b/attachment.sig>

Posted on the users mailing list.