Vectors and Maps in Clojure
;; So I can create a map pretty easily
user=> (def a-map { :name "Nick" :age 1000 })
#'user/a-map
;; and get a value from it with the key
user=> (get a-map :name)
"Nick"
;; I also know how to create a vector (in this case of maps)
user=> (def a-vec [ { :name "Nick" :age 1000 } { :name "Bob" :age 45 } ])
#'user/a-vec
;; retrieving from it seems simple enough
user=> (first a-vec)
{:age 1000, :name "Nick"}
user=> (get a-vec 0)
{:age 1000, :name "Nick"}
;; What I am confused about is why a map's key is a function to the map
user=> (:name a-map)
"Nick"
;; but the same isn't true for a vector
user=> (0 a-vec)
ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn user/eval1388 (NO_SOURCE_FILE:1)
;; yet the converse is fine with a vector
user=> (a-map :nick)
nil
user=> (a-vec 0)
{:age 1000, :name "Nick"}
user=>