def Arrays.leaves
import bend-osdev-array@0.1.0.1/array.bend as Arrayimport Base
35# the slots of an array, in index order: the list model the laws compare
36# Array.get and Array.set with (a specification: it walks the whole array)
37def Arrays.leaves(-T: Data, a: Array<T>) -> List<&2, T>:
38 match a:
39 case ALeaf{x}:
40 Con{x, Nil{}}
41 case ANode{xs, ys}:
42 List.append(&2, T, Arrays.leaves(T, xs), Arrays.leaves(T, ys))