def Balanced
import bendtorch-core@0.1.0.0/src/storage/model.bend as Modelimport Base
45def Balanced(-T: Type, d: Nat, array: Array<T>) -> Type:
46 match d array:
47 case 0n ALeaf{x}:
48 Unit
49 case 0n ANode{xs, ys}:
50 Empty
51 case 1n+p ALeaf{x}:
52 Empty
53 case 1n++p ANode{xs, ys}:
54 Balanced(T, p, xs) & Balanced(T, p, ys)