def Heap.to_list.go
import bend-kit-collections@0.1.4.1/heap.bend as Heapimport Base
85def Heap.to_list.go(
86 ~A: Data, ~le: A -> A -> Bool, fuel: Nat, h: Heap<A>
87) -> List<&2, A>:
88 match fuel:
89 case 0n:
90 Nil{}
91 case 1n+f:
92 match h:
93 case HLeaf{}:
94 Nil{}
95 case HNode{n, x, l, r}:
96 x <> Heap.to_list.go(~A, ~le, f, Heap.merge(~A, ~le, l, r))