Last active
December 16, 2015 07:39
-
-
Save Bost/5400289 to your computer and use it in GitHub Desktop.
clojure - collections
This file contains 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
(defn persistent-hash-map [k v] | |
"Create PeristentHashMap - performs faster for larger maps" | |
(hash-map k v)) | |
(type (persistent-hash-map :a 1)) | |
(defn persisten-array-map [k v] | |
"Create PeristentArrayMap - only suitable for very small maps" | |
{k v}) | |
(type (persisten-array-map :a 1)) | |
; clojure.lang.PeristentHashMap - performs faster for larger maps | |
(def y {:a 1}) | |
(type y) | |
; clojure.lang.Var | |
(type (def y {:a 1})) | |
(def y {:a 1}) | |
; clojure.lang.PeristentHashMap - performs faster for larger maps | |
(type y) | |
; clojure.lang.PersistentList | |
(type '(def y {:a 1})) | |
; clojure.lang.PeristentArrayMap - only suitable for very small maps | |
(type {:a 1}) | |
; clojure.lang.PersistentHashSet | |
(type #{1 2}) | |
{} ;hash-map | |
#{} ;hash-set | |
() ;list | |
[] ;vector |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment