def masked

bendtorch-core@0.1.0.0 · src/autograd/reduce_fiber_proof.bend:236

import bendtorch-core@0.1.0.0/src/autograd/reduce_fiber_proof.bend as ReduceFiberProof
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape

236# The contribution offsets base + walk_right(p) of the positions
237# p = cursor .. cursor + fuel - 1 whose walk_left is `target`, in order:
238# the words the masked fold of `ReduceLaws.fiber` adds.
239def masked(fuel: Nat, +rows: List<&2, Shape.Row>, +target: Nat, +base: Nat, +cursor: Nat) -> List<&2, Nat>:
240  match fuel:
241    case 0n:
242      Nil{}
243    case 1n+rest:
244      kept(Nat.is_eq(Shape.walk_left(rows, cursor), target), Nat.add(base, Shape.walk_right(rows, cursor)),
245        masked(rest, rows, target, base, 1n+cursor))

Uses (8)

Used by (17)