def u32s.go

bend-ml-llama@0.2.0.0 · main.bend:1315

import bend-ml-llama@0.2.0.0/main.bend as BendMlLlama
import Base

1315# the decimal numbers in bs, separated by anything that is not a digit; dg says whether bs starts with a digit
1316def u32s.go(bs: List<&2, U32>, dg: Bool, +cur: U32, have: Bool, acc: List<&2, U32>) -> List<&2, U32>:
1317  match bs dg have:
1318    case Nil{} _ True{}:
1319      List.reverse(&2, U32, cur <> acc)
1320    case Nil{} _ False{}:
1321      List.reverse(&2, U32, acc)
1322    case Con{+b, +t} True{} _:
1323      u32s.go(t, digit_head(t), ((cur * 10 : U32) + U32.sub(b, 48) : U32), True{}, acc)
1324    case Con{b, +t} False{} True{}:
1325      u32s.go(t, digit_head(t), 0, False{}, cur <> acc)
1326    case Con{b, +t} False{} False{}:
1327      u32s.go(t, digit_head(t), 0, False{}, acc)

Uses (8)

Used by (1)