Skip to content

Instantly share code, notes, and snippets.

@bkersten
bkersten / gist:1388295
Created November 23, 2011 09:45
select-vals returns a list of map values in the order of the supplied key sequence
(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)))

Keybase proof

I hereby claim:

  • I am bkersten on github.
  • I am bkersten (https://keybase.io/bkersten) on keybase.
  • I have a public key ASBV0Zi9nEUuScuXVw6D1ltCEpPY7KrqXJFk_YYxmnMK2Ao

To claim this, I am signing this object: