Well, you can always use the (time) macro and pick what runs faster:
(dorun (map some-fn-with-side-effects sequence-1 sequence-2))
(doseq [x (map some-fn-with-side-effects sequence-1 sequence-2))])
(doseq) could be faster in some cases because its implementation uses
chunked sequences. Now, (dos
First: Thanks all for your thoughts.
Second: I have the same question as Allen (why would the doseq variant
be faster in this case?)
Finally: so I guess that what I did was also OK then?
Jm
On Jan 20, 9:57 pm, Alan Malloy wrote:
> But I don't see any reason why this would be faster than (dorun
(dorun (map f xs ys zs)) creates and discards a cons for each
iteration, no argument there. But its first element is very cheap:
just the result of f, which you had to compute anyway.
(doseq [[x y z] (map vector xs ys zs)] (f x y z)) similarly creates a
cons for each iteration. But its value, rath
Ah. Nevermind.
--
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
Hi,
Am 23.01.2012 um 17:40 schrieb Armando Blancas:
> Can you point to where that's happening? I can only see an iteration
> of next over the sequence returned by map.
Exactly. And what does (map f xs) return? (cons (f (first xs)) (map f (rest
xs))). Each such a cons is created for one step of
Shameless plug: If you want to do this type of iteration efficiently, try my
library at https://github.com/jpalmucci/clj-iterate
user> (iter {for x in '(1 2 3)}
{for y in '(a b c)}
(println x y))
1 a
2 b
3 c
nil
user>
Expands into a fast loop/recur form. No intermediate data structu
Can you point to where that's happening? I can only see an iteration
of next over the sequence returned by map.
On Jan 23, 6:43 am, "Meikel Brandmeyer (kotarak)"
wrote:
> And (dorun (map )) is creating a cons with a random value (most likely nil)
> and traverses it and throws it away at every seq
And (dorun (map )) is creating a cons with a random value (most likely nil)
and traverses it and throws it away at every sequence step. YMMV.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.co
On Fri, Jan 20, 2012 at 3:57 PM, Steve Miner wrote:
>
> On Jan 20, 2012, at 2:41 PM, Lars Nilsson wrote:
>
>> => (map #(vector %1 %2) [1 2 3] ['a 'b 'c])
>> ([1 a] [2 b] [3 c])
>
> Sorry if I'm drifting a bit off topic, but I just wanted to point out that
> it's convenient to use just the funct
But I don't see any reason why this would be faster than (dorun (map
side-effect-fn s1 s2 s3)). You're creating and then dismantling a
three-element vector at every iteration to no purpose.
On Jan 20, 12:40 pm, Meikel Brandmeyer wrote:
> Hi,
>
> to add to Lars answer:
>
> (doseq [[a b c] (map vec
On Jan 20, 2012, at 2:41 PM, Lars Nilsson wrote:
> => (map #(vector %1 %2) [1 2 3] ['a 'b 'c])
> ([1 a] [2 b] [3 c])
Sorry if I'm drifting a bit off topic, but I just wanted to point out that it's
convenient to use just the function name if the arguments are already in the
appropriate order.
Hi,
to add to Lars answer:
(doseq [[a b c] (map vector s1 s2 s3)]
(side-effect-fn a b c))
This should do the trick.
Sincerely
Meikel
--
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
No
On Fri, Jan 20, 2012 at 8:18 AM, joachim wrote:
> Hi All,
>
> Here is a simple problem for which I nevertheless can't seem to find
> the right solution: How to run over several sequences in parallel for
> side-effects? Here is one way:
>
> (dorun (map some-fn-with-side-effects sequence-1 seque
Hi All,
Here is a simple problem for which I nevertheless can't seem to find
the right solution: How to run over several sequences in parallel for
side-effects? Here is one way:
(dorun (map some-fn-with-side-effects sequence-1 sequence-2))
However, I was told that the form "(dorun (map ...
14 matches
Mail list logo