[racket] idiomatic way to take elements from a thunk?

From: Richard Cleis (rcleis at me.com)
Date: Thu Sep 20 00:20:20 EDT 2012

WARNING: MARGINAL ANSWER AHEAD

I like the following a little more.

(build-list 10 (lambda(v) (thunk)))

rac

On Sep 19, 2012, at 9:57 PM, John Clements wrote:

> WARNING: TOTALLY UNIMPORTANT QUESTION AHEAD.
> 
> I want to enumerate the first 10 values returned by a thunk. I came up with 
> 
> (define thunk (lambda () 14))
> 
> (for/list ([i 10][e (in-producer thunk #f)]) e)
> 
> … but I feel like there must be some way to simply write (stream-take thunk 10). Am I missing something obvious?
> 
> 
> John
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.