Chapter 3 - Maps, Sets and Keywords Flashcards

1
Q

Function to create a new map

A

hash-map (unordered map) OR sorted-map (ordered map)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Function to get a value of a map

A

get

ex: (get book “author”) OR SIMPLY (book “author”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Keywords

A

basic data type that comes packaged with Clojure.

:key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Function to “add” a new key to a map (or vector) or to “change” a value associated with it

A

assoc

ex: (assoc book :pages 220)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Function to “remove” a key (or keys) of a map (or vector)

A

dissoc

ex: (dissoc book :pages)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Function to get all keys in a map

A

keys

ex: (keys books)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Function to get all values in a map

A

vals

ex: (vals books)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Function to check set membership

A

contains?

ex: (contains? books “1984”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Function to “add” a value to a set

A

conj

ex: (conj books “Brave New World”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Function to “remove” a value from a set

A

disj

ex: (disj books “1984”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly