Fork me on GitHub
Matthew Twomey04:02:58

I want this same result:

(->> {:one "one" :two "two" :three "three"} vec flatten) 
;; => (:one "one" :two "two" :three "three")
I feel like I might be missing a single function that does this?

Matthew Twomey04:02:43

(mapcat seq {:one "one" :two "two" :three "three"}) also does it - but still seems like it should be more simple.


iterleave its keys and values. but be aware that you are going from an unordered structure to an ordered one. The way you "see" the map or think it should order might not be what you end up with.

Matthew Twomey04:02:43

well, what I do care about is that the pairs stay next to each other. I don’t care about the order of the pairs themselves.


good. then (defn as-seq [m] (interleave (keys m) (vals m))) should do it for you


although nothing really wrong with your mapcat seq solution

Matthew Twomey04:02:29

Oh yeah - ok, cool. I’m finding lots of ways to do this I see. I haven’t run into interleave yet - thanks for pointing it out!

👍 1

(into [] cat {:one "one" :two "two" :three "three"})

👀 1