def run_len

lawful-bytes@0.1.1.0 · defs.bend:57

import lawful-bytes@0.1.1.0/defs.bend as Defs
import Base

57# How many leading elements are not c.
58def run_len(xs: List<&2, U32>, +c: U32) -> Nat:
59  match xs:
60    case Nil{}:
61      0n
62    case Con{+x, t}:
63      Bool.pick(Nat, U32.is_eq(x, c), 0n, Nat.add(1n, run_len(t, c)))

Uses (6)

Used by (34)