Re: For loop question

2010-03-21 Thread Michał Marczyk
On 20 March 2010 17:17, David Nolen dnolen.li...@gmail.com 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

Re: For loop question

2010-03-20 Thread Heinz N. Gies
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 1 2 1 3 1

Re: For loop question

2010-03-20 Thread Michał Marczyk
On 20 March 2010 13:05, WoodHacker ramsa...@comcast.net 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

Re: For loop question

2010-03-20 Thread DmitriKo
I guess you want this: (for [x (range 4) y (range 4)] (str x y)) -- DmitriKo On Mar 20, 2:05 pm, WoodHacker ramsa...@comcast.net 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

Re: For loop question

2010-03-20 Thread David Nolen
On Sat, Mar 20, 2010 at 8:05 AM, WoodHacker ramsa...@comcast.net 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