def replace_at_go

mlbend-preprocess@0.1.0.0 · main.bend:239

import mlbend-preprocess@0.1.0.0/main.bend as MlbendPreprocess
import Base

239# A list with its nth element replaced, element by element.
240def replace_at_go(+xs: List<&2, F32>, +n: Nat, +v: F32, +acc: List<&2, F32>) -> List<&2, F32>:
241  match xs:
242    case Nil{}:
243      acc
244    case Con{h, +t}:
245      match n:
246        case 0n:
247          List.append(&2, F32, acc, Con{v, t})
248        case _:
249          replace_at_go(t, Nat.sub(n, 1n), v, List.append(&2, F32, acc, Con{h, Nil{}}))

Uses (5)

Used by (1)