Clojure Programming/Examples/API Examples/Advanced Data Structures

get
get also accepts an optional third argument which is returned if key is not found in map:

merge
Combine two maps into a more massive map

Using merge-with (ClojureDocs) you can specify what course of action to take for collisions, here we decide to join collisions into a set using union (sets in the Cookbook):

assoc
See struct-map for more.

defstruct
See struct-map for more.

struct
See struct-map for more.

zipper
A zipper is a way to modify a tree in a functional way- To do this conveniently, there needs to be a way for you to "drill down" a branch in the tree and perform a local edit, without having to tediously rebuild the upper areas of the tree again. In this example, the vector-zip function converts nested arrays into a zipper. Then we "drill down" the zipper with "down" and "right". Once we've reached the node we want to edit, we do so with "edit", in this case, incrementing the number. Then we can call "root" to convert the zipper back into nested arrays. Note that we were able to efficiently make a pinpoint change in the tree in a very elegant manner.