nsorg.zip
Functions for working with zippers.
ancestors
(ancestors zloc)
Return seq of zipper nodes that are ancestors of the given zipper node.
Parameters:
zloc - zipper node
order-node-pairs
(order-node-pairs zlocs)
Order given zipper node pairs alphabetically by sexpr value of left element of the pair. If sexpr is sequential,
use the sexpr value of the first item for sorting.
Parameters:
zlocs - zipper node pairs to sort
order-nodes
(order-nodes zlocs)
Order given zipper nodes alphabetically by their sexpr value. If sexpr is sequential, use the sexpr value of the
first item for sorting.
Parameters:
zlocs - zipper nodes to sort
order-sexpr
(order-sexpr zloc)
(order-sexpr zloc {:keys [exclude-first? map?], :as opts})
Order child zipper nodes of given collection zipper node.
Parameters:
zloc - collection zipper node
exclude-first? - exclude first element of collection from sorting (default: false)
map? - collection is map and nodes should be ordered as pairs (default: false)
remove-duplicates-from-sexpr
(remove-duplicates-from-sexpr zloc)
(remove-duplicates-from-sexpr zloc {:keys [exclude-first? map?]})
Remove duplicates from child zipper nodes of given collection zipper node.
Map entries are considered duplicates if they they have the same value (not key).
Parameters:
zloc - collection zipper node
exclude-first? - exclude first element of collection from duplicate removal (default: false)
map? - collection is map and nodes should be treated as pairs (default: false)
right-nodes
(right-nodes zloc)
Return seq of zipper nodes that are right siblings of the given zipper node.
Parameters:
zloc - zipper node
sexpr
(sexpr zloc)
Like `rewrite.clj.zip/sexpr but returns nil for nodes that are printable-only.