On 20 March 2010 17:17, David Nolen wrote:
> You can do what you want with the following:
>
> (doseq [[x y] (for [y (range 4) x (range 4)] [x y])]
> (println x y))
Or just
(doseq [y (range 4)
x (range 4)]
(println x y))
doseq really has exactly the same syntax as for (including supp
On Sat, Mar 20, 2010 at 8:05 AM, WoodHacker wrote:
> When I run the following:
>
>(for [y (range 4)] (for [x (range 4)] (println x y)))
>
> I get what I expect - 0 0, 1 0, 2 0, 3 0 etc., but at the end of
> each y loop I also get 4 nils.
>
> ((0 0
> 1 0
> 2 0
> 3 0
> nil nil nil nil) (0 1
>
I guess you want this:
(for [x (range 4) y (range 4)] (str x y))
--
DmitriKo
On Mar 20, 2:05 pm, WoodHacker wrote:
> When I run the following:
>
> (for [y (range 4)] (for [x (range 4)] (println x y)))
>
> I get what I expect - 0 0, 1 0, 2 0, 3 0 etc., but at the end of
> each y loop I als
On 20 March 2010 13:05, WoodHacker wrote:
> What's going on? And how do I fix it? Adding a :when to test for
> nil does not seem to do anything.
You'll want to use 'doseq' in place of 'for'. It uses exactly the same
syntax as for, but is used solely for side effects (the return value
is nil)
On Mar 20, 2010, at 13:05 , WoodHacker wrote:
> When I run the following:
>
>(for [y (range 4)] (for [x (range 4)] (println x y)))
>
> I get what I expect - 0 0, 1 0, 2 0, 3 0 etc., but at the end of
> each y loop I also get 4 nils.
>
> ((0 0
> 1 0
> 2 0
> 3 0
> nil nil nil nil) (0 1
> 1