TraversalLoop.run_then: def of stelliferous@0.0.2.0 Import: import stelliferous@0.0.2.0/traversal_loop.bend as TraversalLoop Lines 10-16 of stelliferous@0.0.2.0/traversal_loop.bend: https://jend.leeeet.dev/read.txt?path=stelliferous@0.0.2.0/traversal_loop.bend&start_line=10&end_line=16 import Base # The same loop handing its final state to finish in the base case. A caller # that stores its accumulators in finish keeps them out of the loop's return # value, so an outlined loop never passes accumulators back by value. def run_then(~State: Type,~Result: Type,~step: State -> State,~finish: State -> Result,count: Nat,state: State) -> Result: match count: case 0n: finish(state) case 1n+rest: run_then(~State,~Result,~step,~finish,rest,step(state)) Uses (1): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat