def run_guarded

stelliferous@0.0.2.0 · tensor_access.bend:34

import stelliferous@0.0.2.0/tensor_access.bend as TensorAccess
import Base
import stelliferous@0.0.2.0/traversal_array.bend as Traversal
import stelliferous@0.0.2.0/traversal_loop.bend as Loop
import stelliferous@0.0.2.0/tensor_cursor.bend as Cursor

34# Runs are used when the cursor starts a full run and count is a whole number
35# of runs; any other call steps element by element. Both visit the same
36# elements in the same order.
37def run_guarded(~Element: Data,~inside: Traversal.State<&1,&1,Array<Element>,Array<Element>,Cursor.Stride> -> Traversal.State<&1,&1,Array<Element>,Array<Element>,Cursor.Stride>,~last: Traversal.State<&1,&1,Array<Element>,Array<Element>,Cursor.Cursor> -> Traversal.State<&1,&1,Array<Element>,Array<Element>,Cursor.Cursor>,full_run: Bool,whole_runs: Bool,runs: Nat,count: Nat,cursor: Cursor.Cursor,destination: U32,
38  input: Array<Element>,output: Array<Element>) -> Array<Element> & Array<Element>:
39  match full_run whole_runs:
40    case True{} True{}:
41      Traversal.finish(~Array<Element>,~Element,~Cursor.Cursor,
42        Loop.run(~Traversal.State<&1,&1,Array<Element>,Array<Element>,Cursor.Cursor>,~run_step(~Element,~inside,~last),runs,
43          Traversal.State{input,output,destination,cursor}))
44    case full_run whole_runs:
45      Traversal.finish(~Array<Element>,~Element,~Cursor.Cursor,
46        Loop.run(~Traversal.State<&1,&1,Array<Element>,Array<Element>,Cursor.Cursor>,~last,count,Traversal.State{input,output,destination,cursor}))

Uses (11)

Used by (2)