Std.Tree.foldTree
1 declaration
fn
foldTree: &Std.Tree.Tree[A] -> fn(A, Array[B]) -> B -> BThis is a callable function.
What it does
Each node combined with what its children answered.
The general fold over this shape, and the one the others are special cases
of: size is a fold that adds one to the sum below, height is a fold that
adds one to the largest, preorder is a fold that prepends. A node is given
its own value and the answers from beneath it, so anything that depends on a
subtree can be written without a second walk.
Read the signature
- The text after the name is the type checked by Pudu.
- Read arrows from left to right: inputs come first, and the final type is returned.
- & borrows a value for this call instead of moving or copying it.
- Names inside [ ] are type arguments, such as the item type held by a collection.
