Rose tree indexing by Gorn address #
Navigation into an n-ary RoseTree by a Gorn address: a List ℕ path of child
indices. subtreeAt returns the subtree reached by descending along the path,
get? its root value, getD with a fallback.
Unlike BinaryTree.get (indexed by a PosNum left/right path) there is no
indexOf: that is a binary-search-tree lookup, which has no analogue for a
general (unordered-search) rose tree. The Gorn path replaces the PosNum path,
so this file needs no Num dependency.
The subtree at a Gorn address (a path of child indices); none if the
path steps outside the tree.
Equations
Instances For
@[simp]
The root value at a Gorn address; none if the path steps outside the tree.
Equations
- t.get? path = Option.map RoseTree.value (t.subtreeAt path)