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 ove
On Tue, Nov 15, 2011 at 04:52:04PM +, 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))
doall
http://clojuredocs.org/c
(def x (doall (map fn coll)))
On Tue, Nov 15, 2011 at 11:52 AM, 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
`doall` will force the realization of any provided lazy sequence, e.g.:
(doall (map fn coll))
- Chas
On Nov 15, 2011, at 11:52 AM, 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
> 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 could do (last x) and drop that value.
U
--
You received this message because you are subscri