On Tue 19/10/10 06:57 , Rising_Phorce josh.fe...@gmail.com sent:
> Nested For(s) produce lists of lists:
> 
> =>(for [x (range 5)]
> (for [y (range 5)]
> y))
> 
> ((0 1 2 3 4) (0 1 2 3 4) (0 1 2 3 4) (0 1 2 3 4) (0 1 2 3 4))
> 
> I want to use for(s) in order to use the loop counters from the
> bindings, but can I produce a list of values (flattened) without
> having to flatten the resultant list?
> 
> (0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4)
> 
> Thanks.

Hi,

A single for expression can iterate over multiple sequences.

Eg:

user=> (for [x (range 3) y (range 5)] y)
(0 1 2 3 4 0 1 2 3 4 0 1 2 3 4)

Check (doc for) for more details.

-- 
Dave

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