Paste number 113394: ensure coll before merging with concat

Paste number 113394: ensure coll before merging with concat
Pasted by: scottj
When:1 year, 9 months ago
Share:Tweet this! | http://paste.lisp.org/+2FHU
Channel:None
Paste contents:
Raw Source | XML | Display As
(let [ensure-coll #(if (coll? %) % (vector %))]
  (merge-with #(apply concat (map ensure-coll %&))
              {:a 1} {:a [2]} {:a [3] :b 1}))

; returns {:b 1, :a (1 2 3)}

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.