Update values in such nested maps. To see it in action, imageineyou wanted to increase Keyle’s monthly average by 500

=> (update-in users [:kyle :summary :average :monthly] + 500)

{:kyle

{:date-joined "2009-01-01",

:summary

{:average

{:monthly 1500, :yearly 12000}}}}

Sequences

A seauence isn’t a collection type. Rather, a sequence is an interface (called ISeq) that expose a “one thing followed by more things” abstraction.

The sequence abstraction allows all data structures to look and act like lists, even if the underlying values are some other collection type (such as a vector or hash map) or are even created laxily as they’re needed.

The ISeq interface provides three functions: first, rest and cons.

(first (list 1 2 3))

;=> 1

(rest (list 1 2 3))

;=> (2 3)

(first [1 2 3])

;=> 1

(rest [1 2 3])

;=> (2 3)

(first {:a 1 :b 2})

;=> [:b 2]

(rest {:a 1 :b 2})

;=> ([:a 1])

(first [])

;=> nil

(rest [])

;=> ()

first returns the first element of the sequence like peek does for lists but the same

way on all collection types. rest returns the sequences without the first element just

like pop does on lists but the same way on all collection types and without throwing an

exception for empty things.

cons (short for construct) creates new sequences given an element and an existing