Created
March 18, 2016 04:17
-
-
Save alandipert/1700e9e6b8187a75158b 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
| (def-map-type MapLayer [hm dissoced m mta] | |
| (get [_ k default-value] | |
| (let [v (get m k ::none)] | |
| (if (= v ::none) | |
| (if (contains? dissoced k) | |
| default-value | |
| (get hm k default-value)) | |
| v))) | |
| (assoc [_ k v] | |
| (MapLayer. hm (disj dissoced k) (assoc m k v) mta)) | |
| (dissoc [_ k] | |
| (MapLayer. hm (conj dissoced k) (dissoc m k) mta)) | |
| (keys [_] | |
| (vec (set/union (set/difference (set (keys hm)) dissoced) (set (keys m))))) | |
| (meta [_] mta) | |
| (with-meta [_ mta] | |
| (MapLayer. hm dissoced m mta))) | |
| (defn map-layer | |
| "Civilizes java.util.Maps" | |
| [java-hashmap] | |
| (MapLayer. java-hashmap #{} {} {})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment