def visited
bendtorch-core@0.1.0.0 · src/autograd/reduce_fiber_proof.bend:247
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
import bendtorch-core@0.1.0.0/src/autograd/reduce.bend as Reduce
247
248def visited(+rows: List<&2, Shape.Row>, +extents: List<&2, Nat>, fuel: Nat, +target: Nat, +base: Nat, +digit: Nat) -> List<&2, Nat>:
249 match rows extents fuel:
250 case Nil{} _ _:
251 [base]
252 case Shape.Row{+stride, +left, +right} <> +rest +extent <> +others 0n:
253 Nil{}
254 case Shape.Row{+stride, +left, +right} <> +rest +extent <> +others 1n+remaining:
255 +inner = Nat.mod(target, left)
256 List.append(&2, Nat,
257 visited(rest, others, Reduce.first_span(rest, others), inner, Nat.add(base, Nat.mul(right, digit)), Reduce.first_digit(rest, inner)),
258 visited(rows, extents, remaining, target, base, 1n+digit))
259 case Shape.Row{+stride, +left, +right} <> +rest Nil{} _:
260 Nil{}