Created
August 22, 2016 08:38
-
-
Save RutledgePaulV/01d8b1d47dd3ada0eff2c15120066025 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 aliasing [& keys-and-values] | |
"Creates a map from pairs of vector/value entries. Each entry in the vector is used as a key for the corresponding value." | |
(loop [result {} entries (into [] (partition 2 keys-and-values))] | |
(let [entry (first entries) keys (first entry) value (second entry)] | |
(if (empty? entries) | |
result | |
(recur (merge result (zipmap keys (repeatedly #(identity value)))) (rest entries)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment