def blank.find
import cswap-bend-cli@0.1.0.0/frame.bend as Frameimport Base
25# Index of the LF that ends a blank line: an LF whose previous line break was
26# an LF too (CR before either is ignored). `prev`: the last significant
27# character was an LF (true at the start, so leading blank lines are cut).
28def blank.find(s: String, +n: Nat, +prev: Bool) -> Maybe<&2, Nat>:
29 match s:
30 case SNil{}:
31 None{}
32 case SCon{Chr{+c}, t}:
33 nl.pick(prev && U32.is_eq(c, 10), n, blank.find(t, Nat.add(n, 1n), Bool.pick(Bool, U32.is_eq(c, 13), prev, U32.is_eq(c, 10))))