Created
October 1, 2012 21:41
-
-
Save amalloy/3814637 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
(defmap AList [entries meta] | |
IPersistentMap | |
(count [this] | |
(count entries)) | |
(valAt [this k not-found] | |
(if-let [e (find this k)] | |
(val e) | |
not-found)) | |
(entryAt [this k] | |
(first (filter #(= k (key %)) entries))) | |
(empty [this] | |
(AList. () meta)) | |
(seq [this] | |
(seq entries)) | |
(assoc [this k v] | |
(AList. (cons (MapEntry. k v) entries) meta)) | |
(without [this k] | |
(AList. (->> entries (remove #(= k (key %))) | |
(apply list)) | |
meta)) | |
IObj | |
(meta [this] | |
meta) | |
(withMeta [this meta] | |
(AList. entries meta))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment