Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created October 1, 2012 21:41
Show Gist options
  • Save amalloy/3814637 to your computer and use it in GitHub Desktop.
Save amalloy/3814637 to your computer and use it in GitHub Desktop.
(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