Traverse arbitrary Clojure data structures using a visitor (cursor).
Thanks to: http://www.ibm.com/developerworks/library/j-treevisit/
Traverse arbitrary Clojure data structures using a visitor (cursor). Thanks to: http://www.ibm.com/developerworks/library/j-treevisit/
(depth loc)
Return the number of traversals required to reach the current node starting from the root node.
Return the number of traversals required to reach the current node starting from the root node.
(index loc)
Return the 0-based position of the current element inside its collection. This value is only meaningful if the current collection is sequential.
Return the 0-based position of the current element inside its collection. This value is only meaningful if the current collection is sequential.
(node-at loc & traversal-fns)
Return the data node starting at cursor after applying zip/traversal-fns. Returns patterns/NO-RESULT-ERROR if there is no node at the specified position.
Return the data node starting at cursor after applying zip/traversal-fns. Returns patterns/NO-RESULT-ERROR if there is no node at the specified position.
(parent-container loc)
Return's the current node's parent container. If the current node is the root node, returns the current node.
Return's the current node's parent container. If the current node is the root node, returns the current node.
(root-node? n)
Is the cursor at the root of the collection?
Is the cursor at the root of the collection?
(traversable-coll? node)
Is this a kind of collection we can traverse?
Is this a kind of collection we can traverse?
(update-breadcrumb old-path loc)
A breadcrumb vector contains the human-readable path from the root object to the current one in a tree-visit session.
Starting with [] representing the root object in a Clojure nested graph, to maintain the breadcrumb vector, after traversing to a new loc with a call to (zip/next cursor) or similar, call (update-breadcrumb old-breadcrumb new-loc) to obtain a new breadcrumb vector corresponding with the new location.
A breadcrumb vector contains the human-readable path from the root object to the current one in a tree-visit session. Starting with [] representing the root object in a Clojure nested graph, to maintain the breadcrumb vector, after traversing to a new loc with a call to (zip/next cursor) or similar, call (update-breadcrumb old-breadcrumb new-loc) to obtain a new breadcrumb vector corresponding with the new location.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close