Created
October 5, 2010 07:51
-
-
Save neotyk/611192 to your computer and use it in GitHub Desktop.
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
(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