Calling a function with variadic “named argument” keyword destructuring using a flat sequence from a map
;; Problem: You have a fn which uses map destructuring to effect
;; "named argument" behavior, and that's nice for callers that want to
;; use it like (foo :a 1 :b 2). But, what if you want to stage up the
;; arguments using a map, and then call foo at your convenience. You
;; have a map now, not an array of args. Here's how you call that
;; variadic named-argument function with your map:
(defn foo
[& {:keys [a b] :as opts}]
(prn-str "you said: " opts))
;; How you'd call it "normally"
(foo :a 1 :b 2)
;; How you call it with a map in hand.
(apply foo (apply concat (vec {:a 1 :b 2})))
Tweet