Skip to content

Instantly share code, notes, and snippets.

View kylecbrodie's full-sized avatar

Kyle Brodie kylecbrodie

View GitHub Profile

Keybase proof

I hereby claim:

  • I am kylecbrodie on github.
  • I am 0_based_kyle (https://keybase.io/0_based_kyle) on keybase.
  • I have a public key ASBS5E1RWBThgpf1X043AO6GBnQBRJu9iHCponF66DUhKAo

To claim this, I am signing this object:

@kylecbrodie
kylecbrodie / clean.clj
Created August 2, 2012 19:35
Cleans a map to remove nil, empty and false values
(defn filter-map
"Returns a map with only the pairs that (pred key value) returned true"
[pred m]
(select-keys m (filter #(pred % (m %)) (keys m))))
(defn clean-map
"Takes a map and removes all nil's, empty data structs, and
falses as these can be implied by them not being there."
[m]
(filter-map (fn [key val] (if (or (true? val)