def list.chunks
import bend-kit-property@0.4.0.0/shrink.bend as Shrinkimport Base
43# Every run of k elements at offsets o, o + k, ... that fits in n; stop tells whether o + k > n.
44def list.chunks(-A: Data, f: Nat, stop: Bool, +o: Nat, +k: Nat, +n: Nat, +xs: List<&2, A>) -> List<&1, List<&2, A>>:
45 match f stop:
46 case 0n _:
47 Nil{}
48 case 1n+p True{}:
49 Nil{}
50 case 1n+p False{}:
51 +e = (o + k : Nat)
52 List.append(&2, A, List.take(&2, A, xs, o), List.drop(&2, A, xs, e))
53 <> list.chunks(A, p, Nat.is_gt((e + k : Nat), n), e, k, n, xs)