Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
split mixed kw/raw args
(defn split-keyword-args [args]
(loop [remaining-args args
keywords-found {}
args-found []]
(cond
(empty? remaining-args)
[keywords-found args-found]
(keyword? (first remaining-args))
(let [[kw arg & rest] remaining-args]
(recur rest (assoc keywords-found kw arg) args-found))
:else
(let [[arg & rest] remaining-args]
(recur rest keywords-found (conj args-found arg))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.