def shape_ok

mylsm-lsm-store@0.6.0.1 · src/BitTree.bend:223

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

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

Uses (4)

Used by (1)