May 2018
Beginner to intermediate
290 pages
6h 43m
English
In the same way that you can use destructuring to dig into several layers of sequential data structures such as lists or vectors, you can also excavate several layers of maps. For example, given this two-level description of Jane Austen:
| | (def austen {:name "Jane Austen" |
| | :parents {:father "George" :mother "Cassandra"} |
| | :dates {:born 1775 :died 1817}}) |
we can extract the names of her parents with this:
| | (let [{{dad :father mom :mother} :parents} austen] |
| | (println "Jane Austen's dad's name was" dad) |
| | (println "Jane Austen's mom's name was" mom)) |
A good way to look at this kind of two-level map destructuring is from the outside in. At the very outside, we have the basic let structure:
| | (let [<<something-to-bind-to>> ... |
Read now
Unlock full access