Created
February 8, 2012 17:18
-
-
Save andrewvc/1771297 to your computer and use it in GitHub Desktop.
This file contains 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 increment-keys | |
"Given a map and a list of keys, this will return an identical map with those keys | |
with those keys incremented. | |
Keys with a null value will be set to 1." | |
[src-map & xs] | |
(into src-map (map #(vector %1 (inc (get src-map %1 0))) xs))) | |
; Example (increment-keys {:a 2} :a :b) => {:a 3 :b 1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment