Clojure: transform list of pairs/n-tuples into n-tuple of lists

755 views Asked by At

Given a list of an n-tuple,

[[1, "a"], [2, "b"], [3, "c"]]

I would like to obtain

[[1, 2, 3]["a", "b", "c"]]

I think this is probably available as a function in the std. library, like it is in python zip(*lst). But I could not find it unfortunately.

Otherwise i guess I can come up with an implementation using a reduce, etc. But I would prefer a standard clojure function :)

1

There are 1 answers

0
Lee On BEST ANSWER
(apply map vector [[1, "a"], [2, "b"], [3, "c"]])

if you need a vector you can use mapv:

(apply mapv vector [[1, "a"], [2, "b"], [3, "c"]])