<br><br>On Sunday, August 19, 2012, Ian Tegebo wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I want to,<br>
<br>
(take k (in-generator (infinite-generator (yield (random n)))))<br>
<br>
where k and n are positive integers, k<n.<br>
<br>
Unfortunately, 'in-generator' returns a sequence while 'take' needs a<br>
list and calling 'sequence->list' results in an error. So, I thought<br>
maybe I needed 'take' from 'lazy'. But it also complains about the<br>
index being too large.<br></blockquote><div><br></div><div><br></div><div>The take function works on lists, and although what you have in hand is a sequence, not all sequences are lists.</div><div><br></div><div>You should be able to take the first k elements of that sequence like this:</div>
<div><br></div><div>;;;;;;</div><span class="Apple-style-span" style>(for/list ([elt (in-generator (infinite-generator (yield (random n))))]</span><div><span class="Apple-style-span" style> [i k])<br></span></div>
<div><div><div dir="ltr"> elt)</div><div dir="ltr">;;;;;;</div><div dir="ltr"><br></div><div dir="ltr">There may be an easier way to to do this, but using the for/list loop should do the trick. Good luck!<span></span></div>
</div></div>