Chapter 3 - Maps, Sets and Keywords Flashcards
Function to create a new map
hash-map (unordered map) OR sorted-map (ordered map)
Function to get a value of a map
get
ex: (get book “author”) OR SIMPLY (book “author”)
Keywords
basic data type that comes packaged with Clojure.
:key
Function to “add” a new key to a map (or vector) or to “change” a value associated with it
assoc
ex: (assoc book :pages 220)
Function to “remove” a key (or keys) of a map (or vector)
dissoc
ex: (dissoc book :pages)
Function to get all keys in a map
keys
ex: (keys books)
Function to get all values in a map
vals
ex: (vals books)
Function to check set membership
contains?
ex: (contains? books “1984”)
Function to “add” a value to a set
conj
ex: (conj books “Brave New World”)
Function to “remove” a value from a set
disj
ex: (disj books “1984”)