Skip to content

Instantly share code, notes, and snippets.

@mnylen
Created June 4, 2012 18:56
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 mnylen/2870176 to your computer and use it in GitHub Desktop.
Save mnylen/2870176 to your computer and use it in GitHub Desktop.
(def x (transient {}))
(conj! x [\A 1]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\B 2]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\C 3]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\D 4]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\E 5]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\F 6]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\G 7]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\H 8]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\I 9]) ;; => #<TransientHashMap clojure.lang.PersistentHashMap$TransientHashMap@77aa13c5>
(conj! x [\J 10]) ;; => #<TransientHashMap clojure.lang.PersistentHashMap$TransientHashMap@34f5b235>
(persistent! x) ;; => {\A 1, \B 2, \C 3, \D 4, \E 5, \F 6, \G 7, \H 8}
;; Note how the \I and \J keys are missing from the resulting map
;; Also, note that the result from (conj! x [\I 9]) is a different transient map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment