If you're only interested in the side effects of the computation and not the 
result say:

(map #(println %) [1 2 3 4])

you can use dorun rather than doall as it doesn't retain the head (therefore 
requiring less memory).

(dorun (map #(println %) [1 2 3 4]))

Also, if you see yourself mapping over a sequence inside a dorun (as above) you 
should consider doseq:

(doseq [el [1 2 3 4]] (println el))

which requires even less allocation as it doesn't use map which creates a new 
seq.

Sam

---
http://sam.aaron.name

On 15 Nov 2011, at 16:52, labwor...@gmail.com wrote:

> I understand that lazy sequences are very useful but sometimes, I want to 
> compute everything, go away, and have it there when I come back. 
> How do I do that with a map? 
> (def x (map fn coll))
> 
> -- 
> 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

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