def rows_of_class
import mlbend-split@0.1.1.0/main.bend as MlbendSplitimport Base
40# The rows of one class, with their indices.
41def rows_of_class(labels: List<&2, Nat>, +c: Nat, +i: Nat, +acc: List<&2, Nat>) -> List<&2, Nat>:
42 match labels:
43 case Nil{}:
44 acc
45 case Con{h, t}:
46 rows_of_class(t, c, Nat.add(i, 1n),
47 Bool.pick(List<&2, Nat>, Nat.is_eq(h, c), List.append(&2, Nat, acc, Con{i, Nil{}}), acc))