Skip to content

Instantly share code, notes, and snippets.

@tobyhede
Created February 19, 2012 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobyhede/1862108 to your computer and use it in GitHub Desktop.
Save tobyhede/1862108 to your computer and use it in GitHub Desktop.
Clojure idioms

remove nil values from map

(defn remove_nils [col]
  (into {} (remove (comp nil? v) col)))

check if list/collection contains a value

(some #{:value} collection)

sort a vector of maps by key

(sort-by :name [{:name "Toby"} {:name "Zaphod"} {:name "Astrid"}])

iterate over the key value pairs in a map

(doseq [[k v] some-map]
  ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment