(rontolisp) docs
← Reference

clojure.zip

Functional tree editing with zippers. Require clojure.zip to use it; it is Clojure source written for rontolisp from the documented behavior of Clojure's namespace, and runs the same on every backend.

A location (loc) is a vector of the focused node and the path to it; its metadata holds the three functions that make the tree a tree. Moving and editing answer new locs, and root rebuilds the tree with every edit applied.

VarBehavior
zipper(zipper branch? children make-node root): a loc at root of a tree whose branches branch? recognizes, whose children children answers and which make-node rebuilds from a node and a seq of children
vector-zip, seq-zip, xml-zipZippers over nested vectors, nested seqs, and maps of :tag, :attrs and :content
node, branch?, children, make-nodeThe focused node, whether it is a branch, its children, a node rebuilt the zipper's way
path, lefts, rightsThe nodes from the root down to the parent, the left and the right siblings
down, up, left, right, leftmost, rightmostMoves; nil where there is nowhere to go (leftmost/rightmost answer the loc itself)
rootThe root node with every edit applied
replace, edit, insert-left, insert-right, insert-child, append-child, removeEdits; remove answers the loc before the removed node in a depth-first walk
next, prev, end?A depth-first walk: next past the last node answers the end loc, which end? recognizes