A library for constructing multi-way trees. Each Tree carries two pieces of information, it's datum and children.
Flattens a Tree into a List where the root is the first element of that list.
A special version of flatten which flattens a Tree into a List of Tuples like (element, [all elements in subtree])
Tree.tuplesOfDatumAndFlatChildren
Tree
"a"
[ Tree "b" []
, Tree "c" []
, Tree "d" []
]
== [ ( "a", [ "b", "c", "d" ] ), ( "b", [] ), ( "c", [] ), ( "d", [] ) ]Filter the MultiwayTree. Keep only elements whose datum satisfy the predicate.
Filter the MultiwayTree. If the predicate is True for a Child the entire path to the root will be part of the result Tree.
Return the length of the Tree. Calculated recusively as datum (1) + length of children (n) Since a MultiwayTree is never empty this function will never return Int < 1.
Inserts a Tree as the first child of a Tree
Inserts a Tree as the last child of a Tree
Map a Function over a List and a MultiwayTree.
Same as map but the function is also applied to the index of each element (starting at zero).
Sort values by a derived property. Does not alter the nesting structure of the Tree, that is it does not move Nodes up or down levels.
sortBy identity
Tree
"a"
[ Tree "b" []
, Tree "d" []
, Tree "c" []
]
== Tree "a"
[ Tree "b" []
, Tree "c" []
, Tree "d" []
]
A type to keep track of datum and children.