On Tue, Jun 29, 2010 at 17:24, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> On Jun 29, 4:24 pm, B Smith-Mannschott <bsmith.o...@gmail.com> wrote:
>
>> This fully realizes the (range 10000) before calling foo, which is
>> wasteful if foo is written to consume more incrementally.
>>
>> I've run into this trouble with concat, when I've wanted a lazy
>> sequence of the concatenation of the sequences produced by a list
>> comprehension:
>>
>> (apply concat (for [n (range 1000)]
>>                   (range 100)))
>>
>> Concat gets passed a fully realized sequence of 1000 lazy sequences of
>> 100 integers.
>
> I don't think that this is true. Otherwise the following wouldn't
> work:
> user=> (defn take-5 [& more] (take 5 more))
> #'user/take-5
> user=> (apply take-5 (iterate inc 0))
> (0 1 2 3 4)
>
> iterate creates an infinite sequence. So if the problem was apply, the
> second call should not return.
>
> If more than necessary is realised, I suspect some effect with chunked
> seqs.

There's nothing quite as powerful as a good counter example. You're
quite right.

I guess what I'd observed at the time I "discovered" this must have
been the effect of chunking. At the time, I did attempt the understand
the implementation of apply and through I was seeing the args sequence
being realized, but I guess I must have misunderstood the code.

// Ben

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to