Pudu programming language
Menu

Std.Tree.unfoldResult

1 declaration

fn

unfoldResult: S -> fn(S) -> Result[(T, Array[S]), E] -> Result[Std.Tree.Tree[T], E]

This is a callable function.

What it does

A tree grown from a starting value, where growing may fail.

The first failure is the answer and no further seeds are grown. Growing runs

depth first, in the order `unfold` runs, so the failure reported is the one

a reader following the tree downward would meet first. A breadth-first order

would report a different failure for the same input; it is not offered

because there is no way to abstract over the carrier, so each order would be

a separate named function for each carrier.

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.
  • Names inside [ ] are type arguments, such as the item type held by a collection.
  • Result makes success and recoverable failure part of the function's type.

Back to Std.TreeSearch related declarations