Skip to content

Instantly share code, notes, and snippets.

@neotyk
Created October 5, 2010 07:51
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 neotyk/611192 to your computer and use it in GitHub Desktop.
Save neotyk/611192 to your computer and use it in GitHub Desktop.
(ns tmp
(:use clojure.contrib.java-utils))
(def *default* {:a 1})
(def *provided* {:c 2})
(def *mapping*
{:c :b
:a :c
:b :a})
(defn apply-mapping
"Applies mapping to given map."
[map mapping]
(merge map
(loop [m (select-keys map (keys mapping))
ks (seq (keys mapping))]
(if ks
(let [k (first ks)
v (k m)]
(recur (assoc m (k mapping) v)
(next ks)))
m))))
(with-system-properties
(apply-mapping (merge *default* *provided*) *mapping*)
(doseq [k [:a :b :c]] (prn k (get-system-property k))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment