Skip to content

Instantly share code, notes, and snippets.

@raek
Created June 17, 2011 09:22
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 raek/1031113 to your computer and use it in GitHub Desktop.
Save raek/1031113 to your computer and use it in GitHub Desktop.
(defprotocol MutableSnapshot
(mutable [coll]))
(extend-protocol MutableSnapshot
clojure.lang.ISeq
(mutable [coll]
(java.util.LinkedList. (map mutable coll)))
clojure.lang.IPersistentVector
(mutable [coll]
(java.util.ArrayList. (map mutable coll)))
clojure.lang.IPersistentMap
(mutable [coll]
(-> (zipmap (map mutable (keys coll))
(map mutable (vals coll)))
(java.util.HashMap.)))
clojure.lang.IPersistentSet
(mutable [coll]
(java.util.HashSet. (map mutable coll)))
java.lang.Object
(mutable [coll]
coll))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment