clojure.core/tree-seq¶
Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree.
Examples¶
Note by phreed¶
The 'branch?' and 'children' functions perform different types of filtering. The 'branch?' function examines a node and determines whether there are children that need to be included in the processing. The 'children' function selects (or generates) the children to be included in the returned sequence.
Note by lostdiaspora¶
Example 5 has for the second example (tree-seq seq? seq [[1 2 [3]] [4]]) when it should be (tree-seq sequential? seq [[1 2 [3]] [4]])
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.