beginners

pekudzu 2025-11-25T09:45:26.987159Z

say i have a set of vectors (in hiccup): [[:a "hello"] [:a "cruel"] [:a "world"]] what's the clojurey/FP way of inserting a new value between each element? [[:a "hello"] :space [:a "cruel"] :space [:a "world"]] in an imperative context, i would probably have some janky stuff with a counter inside an iterator. i imagine i could use split-at with for , but that feels a lot less elegant than it should be

2025-11-25T09:47:33.839809Z

interpose could do it

👍 2
Ed 2025-11-25T09:48:18.306639Z

user=> (into [] (interpose :space) [[:a "hello"] [:a "cruel"] [:a "world"]])
[[:a "hello"] :space [:a "cruel"] :space [:a "world"]]

🎯 1
pekudzu 2025-11-25T09:49:26.838559Z

ah thank you! slipped straight past my googling

👍 1