Reduction.array_run: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/tensor/reduction.bend as Reduction Lines 71-80 of bendtorch-core@0.1.0.0/src/tensor/reduction.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/tensor/reduction.bend&start_line=71&end_line=80 import Base # The fuel + 1 words of the array from slot `cursor`, whose read `pair` is # already made, added to `accumulator` left to right. Each step reads the # next word and hands it on as an argument: one tail call with no checked # read and no closure per word. def array_run(fuel: Nat, +cursor: Nat, accumulator: F32, pair: Array & F32) -> F32 & Array: match fuel pair: case 0n Tuple{array, word}: (F32.add(accumulator, word), array) case 1n+rest Tuple{array, word}: array_run(rest, 1n+cursor, F32.add(accumulator, word), Array.get(F32, array, U32.from_nat(1n+cursor))) Uses (8): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.get https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat