def shape_ok

mylsm-lsm-store@0.3.2.0 · src/BitTree.bend:225

import mylsm-lsm-store@0.3.2.0/src/BitTree.bend as BitTree
import Base

225# Structural checker for the exact perfect-tree shape described by metadata.
226def shape_ok(+height: Nat, tree: WordTree) -> Bool:
227  match height tree:
228    case 0n Empty{}:
229      False{}
230    case 0n Leaf{word}:
231      True{}
232    case 0n Fork{left, right}:
233      False{}
234    case 1n+h Empty{}:
235      False{}
236    case 1n+h Leaf{word}:
237      False{}
238    case 1n+h Fork{left, right}:
239      a b = shape_ok(h, left) shape_ok(h, right)
240      Bool.and(a, b)

Uses (4)

Used by (1)