You know that (map f seq1 seq2) means call f with one argument from
seq1 and one from seq2 in turn, until one of the sequences has been
exhausted?
Does
=> (map #(vector %1 %2) [1 2 3] ['a 'b 'c])
([1 a] [2 b] [3 c])
Seem like the result you would expect or not, when you talk about "run
over several sequences in parallel"?
Lars Nilsson
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
> => (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. Also, it is sometimes convenient to quote a vector rather than the individual elements. For example, the following is an equivalent expression:
(map vector [1 2 3] '[a b c])
Of course, wrapping the expression in dorun is necessary if you care about forcing side-effects.
I had something else going on inside #() for a while, and later just
switched to vector. Oops.
Lars Nilsson
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 structures
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
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 the input sequence(s). The fact that you don't use the first part of the cons, does not mean it's not created.
Sincerely
Meikel