Skip to content

Instantly share code, notes, and snippets.

@raek
Created June 17, 2011 10:00
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/1031156 to your computer and use it in GitHub Desktop.
Save raek/1031156 to your computer and use it in GitHub Desktop.
(defmulti mutable type)
(defmethod mutable :default [x]
x)
(defmethod mutable clojure.lang.ISeq [coll]
(java.util.LinkedList. (map mutable coll)))
(defmethod mutable clojure.lang.IPersistentVector [coll]
(java.util.ArrayList. (map mutable coll)))
(defmethod mutable clojure.lang.IPersistentMap [m]
(java.util.HashMap. (zipmap (map mutable (keys m))
(map mutable (vals m)))))
(defmethod mutable clojure.lang.IPersistentSet [coll]
(java.util.HashSet. (map mutable coll)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment