Skip to content

Instantly share code, notes, and snippets.

@RutledgePaulV
Created August 22, 2016 08:38
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 RutledgePaulV/01d8b1d47dd3ada0eff2c15120066025 to your computer and use it in GitHub Desktop.
Save RutledgePaulV/01d8b1d47dd3ada0eff2c15120066025 to your computer and use it in GitHub Desktop.
(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