Re: parallel vs serial iteration in a for loop

2010-06-20 Thread Tom Faulhaber
Hi Viksit, I would suggest that the CL loop construct and the Clojure construct of the same name are, in fact, fairly different beasts, both structurally and in terms of their goals. I don't believe that Rich has any intent to extend loop towards the CL flavored loop. The for construct is more

Re: parallel vs serial iteration in a for loop

2010-06-18 Thread viksit
Hey Meikel, On Jun 17, 10:48 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Jun 18, 1:35 am, viksit vik...@gmail.com wrote: (loop for x in '(a b c d e)       for y in '(1 2 3 4 5)       collect (list x y) ) ((A 1) (B 2) (C 3) (D 4) (E 5)) Are there any good (and idiomatic)

Re: parallel vs serial iteration in a for loop

2010-06-18 Thread Moritz Ulrich
Personally, I think the cl loop-macro is kind of ugly. Yes, it's a nice dsl for looping, but it is almost too powerful for my taste. Too complicated to learn, if you can accomplish the same thing with sexps. However, you can combine doseq, destructuring and the map-stuff by Meikel Brandmeyer to

Re: parallel vs serial iteration in a for loop

2010-06-17 Thread Meikel Brandmeyer
Hi, On Jun 18, 1:35 am, viksit vik...@gmail.com wrote: (loop for x in '(a b c d e)       for y in '(1 2 3 4 5)       collect (list x y) ) ((A 1) (B 2) (C 3) (D 4) (E 5)) Are there any good (and idiomatic) methods to achieve this using a Clojure loop construct? user= (map vector [:a :b

Re: parallel vs serial iteration in a for loop

2010-01-10 Thread Sean Devlin
Conrad, What's your use case that requires for and not map? I haven't seen something like this yet, and you've got my curious. Sean On Jan 8, 4:41 pm, Conrad drc...@gmail.com wrote: Thanks again Sean/Chouser- Sounds like there isn't any easy way to do in-step iteration using the for

Re: parallel vs serial iteration in a for loop

2010-01-08 Thread Sean Devlin
Take a look at pmap On Jan 8, 11:13 am, Conrad drc...@gmail.com wrote: Looping variables in a clojure for loop are iterated in a serial, cartesian fashion: (for [a (range 5) b (range 10 15)]        (+ a b)) (10 11 12 13 14 11 12 13 14 15 12 13 14 15 16 13 14 15 16 17 14 15 16 17 18) I

Re: parallel vs serial iteration in a for loop

2010-01-08 Thread Chouser
On Fri, Jan 8, 2010 at 11:34 AM, Sean Devlin francoisdev...@gmail.com wrote: Take a look at pmap I don't think that's the kind of parallel being asked about. On Jan 8, 11:13 am, Conrad drc...@gmail.com wrote: Looping variables in a clojure for loop are iterated in a serial, cartesian

Re: parallel vs serial iteration in a for loop

2010-01-08 Thread Conrad
Thanks Sean... Sorry, I should have used a better word than parallel- The second code example shows what I mean... I'm not referring to multithreaded parallelism, but simply being able to iterate through two lists in step, as Chouser describes. (as you can do by passing two different seqs to map)

Re: parallel vs serial iteration in a for loop

2010-01-08 Thread Sean Devlin
Oh, right. I saw paralell and the brain hit autopilot. And I think you CAN improve on your fn a little bit. This should do the trick (map + (range 1 5) (range 11 15)) The mapping fn itself will be applied to as many arguments as you have collections. Since + is variadic, it will do the job

Re: parallel vs serial iteration in a for loop

2010-01-08 Thread Conrad
Thanks again Sean/Chouser- Sounds like there isn't any easy way to do in-step iteration using the for construct, as I suspected- This is of course easily remedied for writing a convenience function for (map vec ...) (As I mentioned in the top post, I am aware the simple example I gave can be