On Wed, Aug 24, 2011 at 3:49 PM, Asim Jalis <asimja...@gmail.com> wrote:
> I used "take 0" as a simple example to illustrate the problem. But in general 
> the standard mapcat evaluates terms than are needed. My f function does a web 
> call and processes the JSON records produced by this call, so each extra call 
> is a significant performance and resource hit.

You may be able to wrap each web call in an explicit delay, and
construct your lazy seq of these delays, then force the ones you
actually want to use. Then the expensive JSON calls won't take place
for any element until needed, no matter how far any of the sequence
processing functions look ahead, as long as none of them will need to
peek inside the delays until outside the problematic mapcat. (So,
(mapcat (filter ...)) would be trouble, as the filter predicate may
need to force the delays in the inner sequence, but (filter (mapcat
...)) should be ok unless filter is also looking ahead.)

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
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