Created
November 26, 2012 21:26
-
-
Save charles-dyfis-net/4150725 to your computer and use it in GitHub Desktop.
split mixed kw/raw args
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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