How do you loop two sequences in Clojure? IOW, What is the Clojure Python equivalent of zip(a, b) ?
zip(a, b)
EDIT:I know how to define such a function. I was just wondering if the standard library already provides such a function. (I would be very * surprised if this is not so.)
You can easily define a function like Python zip:
(defn zip [& colls] (apply map vector colls))
In the case of (zip ab) it becomes (map vector ab)
(zip ab)
(map vector ab)
if you want the input to be lists, you can define a zip function like this
(defn zip [m] (apply map list m))
and name it as follows
(zip '((1 2 3) (4 5 6)))
this call calls ((1 4) (2 5) (3 6))
((1 4) (2 5) (3 6))
Is it close enough?
(seq (zipmap [1 2 3] [4 5 6])) ;=> ([3 6] [2 5] [1 4])