Skip to content

Instantly share code, notes, and snippets.

@sunng87
Created November 5, 2014 08:59
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 sunng87/536b67d9014fc5428443 to your computer and use it in GitHub Desktop.
Save sunng87/536b67d9014fc5428443 to your computer and use it in GitHub Desktop.
assoc-some
(defn assoc-some [m & kvs]
(if-not (even? (count kvs))
(throw (IllegalArgumentException. "even number of key-values required."))
(if-let [kvs (not-empty (filter #(some? (second %)) (partition 2 kvs)))]
(apply assoc m (flatten kvs))
m)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment