Created
November 23, 2011 09:45
-
-
Save bkersten/1388295 to your computer and use it in GitHub Desktop.
select-vals returns a list of map values in the order of the supplied key sequence
This file contains 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 select-vals [map keyseq] | |
"Returns a list containing the entries in map whose key is in keys, in order of the supplied keys, with nil in place of keys not found" | |
(loop [ret [] keys (seq keyseq)] | |
(if keys | |
(let [value (first (rest (. clojure.lang.RT (find map (first keys)))))] | |
(recur | |
(if value | |
(conj ret value) | |
(conj ret nil)) | |
(next keys))) | |
ret))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment