Created
November 5, 2014 08:59
-
-
Save sunng87/536b67d9014fc5428443 to your computer and use it in GitHub Desktop.
assoc-some
This file contains hidden or 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 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