filterTree
filterTree<
T
>(x
,f
):Tree
<T
>
Filter children out of a tree by a given predicate.
This function is fully lazy, meaning that we do not evaluate children until they are iterated on. Iteration of the children modify the iterators.
Example
const t = filterTree(tree(1, [tree(2, tree(5)), tree(3)]), (x) => x < 4)showTree(t)// => └─ 1// ├─ 2// └─ 3
showTree(t)// => └─ 1
Type Parameters
• T
Parameters
x
Tree
<T
>
The node root.
f
(x
) => boolean
Returns
Tree
<T
>
A filter tree.