Answers to this question explain how to convert maps, sequences, etc. to various sequences and collections, but do not say how to convert a map to a sequence of alternating keys and values. Here is one way:
(apply concat {:a 1 :b 2})
=> (:b 2 :a 1)
Some alternatives that one might naively think would produce the same result, don't, including passing the map to vec
, vector
, seq
, sequence
, into []
, into ()
, and flatten
. (Sometimes it's easier to try it than to think it through.)
Is there anything simpler than apply concat
?