def split.scan
bend-kit-bytes@0.3.3.0 · bytes.bend:495
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import Base
495
496
497def split.scan(f: Nat, r: Array<U32> & Bool, +sep: String, +m: U32, +i: U32, +skip: U32, +cuts: List<&2, U32>) -> Array<U32> & List<&2, U32>:
498 match f:
499 case 0n:
500 (a, hit) = r
501 (a, cuts)
502 case 1n+p:
503 (a, +hit) = r
504 +take = Bool.and(hit, U32.is_eq(skip, 0))
505 +next = Bool.pick(U32, take, (m - 1 : U32), Bool.pick(U32, U32.is_eq(skip, 0), 0, (skip - 1 : U32)))
506 split.scan(p, at(a, sep, (i + 1 : U32)), sep, m, (i + 1 : U32), next, Bool.pick(List<&2, U32>, take, Con{i, cuts}, cuts))