~/bend-docscommunity

traversal_array.bend checks

raw source on the hub · import stelliferous@0.0.2.0/traversal_array.bend as Traversal_array

One owned read/transform/write traversal. Reader and address mapping are static templates, so composition does not create a closure for each element.

2 imports
import Base
import ./traversal_loop.bend as Loop

Types

type State source · line 12 · raw

@-reader_kind:Quant -> @-output_kind:Quant -> @-Reader:Kind(reader_kind) -> @-Output:Kind(output_kind) -> @-Context:Data -> Kind(reader_kind <&> output_kind)

type Offsets source · line 63 · raw

Data

type Visited source · line 153 · raw

@-Context:Data -> @-Element:Data -> Data

A cursor is consumed by read and returned advanced. The state position is the absolute contiguous destination, so it need not retain a second cursor copy.

type Target source · line 173 · raw

@-Context:Data -> Data

A scatter reads the source at the state position, which counts up, and stores at the address its context names; target yields that address with the context of the next element.

Definitions

def index source · line 57 · raw

@context:Unit -> @position:U32 -> U32

def destination_offset source · line 66 · raw

@context:Offsets -> @position:U32 -> U32

Templates

template write_list source · line 6 · raw

@-Element:Data -> @values:List<&2, Element> -> @+offset:U32 -> @storage:Array<Element> -> Array<Element>

template indexed_step source · line 17 · raw

@-Value:Type -> @-Context:Data -> @-update:(@_:U32 -> @_:Context -> @_:Value -> Value) -> @state:State<&2, &1, Unit, Value, Context> -> State<&2, &1, Unit, Value, Context>

Indexed state updates share the traversal counter without requiring an array destination. The caller establishes any no-wrap bound on the U32 position.

template indexed_output source · line 22 · raw

@-Value:Type -> @-Context:Data -> @state:State<&2, &1, Unit, Value, Context> -> Value

template indexed_fold source · line 26 · raw

@-Value:Type -> @-Context:Data -> @-update:(@_:U32 -> @_:Context -> @_:Value -> Value) -> @count:Nat -> @position:U32 -> @context:Context -> @value:Value -> Value

template write_state source · line 32 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @reader:Reader -> @output:Array<Element> -> @position:U32 -> @context:Context -> @destination:U32 -> @value:Element -> State<&1, &1, Reader, Array<Element>, Context>

template store source · line 36 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-destination:(@_:Context -> @_:U32 -> U32) -> @+position:U32 -> @+context:Context -> @output:Array<Element> -> @result:Pair(Reader, Element) -> State<&1, &1, Reader, Array<Element>, Context>

template step source · line 41 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> @_:U32 -> Pair(Reader, Element)) -> @-destination:(@_:Context -> @_:U32 -> U32) -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template run source · line 47 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> @_:U32 -> Pair(Reader, Element)) -> @-destination:(@_:Context -> @_:U32 -> U32) -> @count:Nat -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template finish source · line 53 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @state:State<&1, &1, Reader, Array<Element>, Context> -> Pair(Reader, Array<Element>)

Return both owners when the caller can reuse the source allocation later.

template read_index source · line 60 · raw

@-Element:Data -> @storage:Array<Element> -> @context:Unit -> @position:U32 -> Pair(Array<Element>, Element)

template source_offset source · line 70 · raw

@-Element:Data -> @input:Array<Element> -> @context:Offsets -> @position:U32 -> Pair(Array<Element>, Element)

template copy source · line 74 · raw

@-Element:Data -> @count:Nat -> @source:U32 -> @destination:U32 -> @input:Array<Element> -> @target:Array<Element> -> Pair(Array<Element>, Array<Element>)

template fold_value source · line 81 · raw

@-Reader:Type -> @-Element:Data -> @-Accumulator:Data -> @-Context:Data -> @-combine:(@_:Accumulator -> @_:Element -> Accumulator) -> @accumulator:Accumulator -> @position:U32 -> @context:Context -> @result:Pair(Reader, Element) -> State<&1, &2, Reader, Accumulator, Context>

Ordered folds share the same state/counter and preserve the combine order. Element and Accumulator can differ; no associativity assumption is required.

template fold_step source · line 87 · raw

@-Reader:Type -> @-Element:Data -> @-Accumulator:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> @_:U32 -> Pair(Reader, Element)) -> @-combine:(@_:Accumulator -> @_:Element -> Accumulator) -> @state:State<&1, &2, Reader, Accumulator, Context> -> State<&1, &2, Reader, Accumulator, Context>

template finish_fold source · line 93 · raw

@-Reader:Type -> @-Accumulator:Data -> @-Context:Data -> @state:State<&1, &2, Reader, Accumulator, Context> -> Pair(Reader, Accumulator)

template fold source · line 97 · raw

@-Reader:Type -> @-Element:Data -> @-Accumulator:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> @_:U32 -> Pair(Reader, Element)) -> @-combine:(@_:Accumulator -> @_:Element -> Accumulator) -> @count:Nat -> @position:U32 -> @reader:Reader -> @initial:Accumulator -> @context:Context -> Pair(Reader, Accumulator)

template mapped_value source · line 105 · raw

@-Element:Data -> @-Context:Data -> @-map:(@_:Context -> @_:Element -> Element) -> @+position:U32 -> @+context:Context -> @result:Pair(Array<Element>, Element) -> State<&2, &1, Unit, Array<Element>, Context>

Reuse the output owner for each read/write; no second array or clone.

template map_step source · line 110 · raw

@-Element:Data -> @-Context:Data -> @-map:(@_:Context -> @_:Element -> Element) -> @state:State<&2, &1, Unit, Array<Element>, Context> -> State<&2, &1, Unit, Array<Element>, Context>

template mapped_output source · line 115 · raw

@-Element:Data -> @-Context:Data -> @state:State<&2, &1, Unit, Array<Element>, Context> -> Array<Element>

template map_in_place source · line 119 · raw

@-Element:Data -> @-Context:Data -> @-map:(@_:Context -> @_:Element -> Element) -> @count:Nat -> @position:U32 -> @context:Context -> @output:Array<Element> -> Array<Element>

template update_sample source · line 126 · raw

@-Reader:Type -> @-Element:Data -> @-Sample:Data -> @-Context:Data -> @-combine:(@_:Element -> @_:Sample -> Element) -> @-destination:(@_:Context -> @_:U32 -> U32) -> @position:U32 -> @context:Context -> @output:Array<Element> -> @current:Element -> @result:Pair(Reader, Sample) -> State<&1, &1, Reader, Array<Element>, Context>

Read the destination's current element, combine it with an owned reader, then store through the same traversal state. Distinct Array owners cannot alias.

template update_current source · line 132 · raw

@-Reader:Type -> @-Element:Data -> @-Sample:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> @_:U32 -> Pair(Reader, Sample)) -> @-combine:(@_:Element -> @_:Sample -> Element) -> @-destination:(@_:Context -> @_:U32 -> U32) -> @reader:Reader -> @+position:U32 -> @+context:Context -> @result:Pair(Array<Element>, Element) -> State<&1, &1, Reader, Array<Element>, Context>

template update_step source · line 138 · raw

@-Reader:Type -> @-Element:Data -> @-Sample:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> @_:U32 -> Pair(Reader, Sample)) -> @-combine:(@_:Element -> @_:Sample -> Element) -> @-destination:(@_:Context -> @_:U32 -> U32) -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template update source · line 145 · raw

@-Reader:Type -> @-Element:Data -> @-Sample:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> @_:U32 -> Pair(Reader, Sample)) -> @-combine:(@_:Element -> @_:Sample -> Element) -> @-destination:(@_:Context -> @_:U32 -> U32) -> @count:Nat -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template visit_store source · line 156 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @+position:U32 -> @output:Array<Element> -> @result:Pair(Reader, Visited<Context, Element>) -> State<&1, &1, Reader, Array<Element>, Context>

template visit_step source · line 161 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> Pair(Reader, Visited<Context, Element>)) -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template visit source · line 166 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> Pair(Reader, Visited<Context, Element>)) -> @count:Nat -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template spread_store source · line 176 · raw

@-Element:Data -> @-Context:Data -> @position:U32 -> @output:Array<Element> -> @target:Target<Context> -> @result:Pair(Array<Element>, Element) -> State<&1, &1, Array<Element>, Array<Element>, Context>

template spread_step source · line 182 · raw

@-Element:Data -> @-Context:Data -> @-target:(@_:Context -> Target<Context>) -> @state:State<&1, &1, Array<Element>, Array<Element>, Context> -> State<&1, &1, Array<Element>, Array<Element>, Context>

template visit_update_sample source · line 187 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-combine:(@_:Element -> @_:Element -> Element) -> @+position:U32 -> @output:Array<Element> -> @current:Element -> @result:Pair(Reader, Visited<Context, Element>) -> State<&1, &1, Reader, Array<Element>, Context>

template visit_update_current source · line 192 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> Pair(Reader, Visited<Context, Element>)) -> @-combine:(@_:Element -> @_:Element -> Element) -> @position:U32 -> @context:Context -> @reader:Reader -> @result:Pair(Array<Element>, Element) -> State<&1, &1, Reader, Array<Element>, Context>

template visit_update_step source · line 197 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> Pair(Reader, Visited<Context, Element>)) -> @-combine:(@_:Element -> @_:Element -> Element) -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template visit_update source · line 202 · raw

@-Reader:Type -> @-Element:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> Pair(Reader, Visited<Context, Element>)) -> @-combine:(@_:Element -> @_:Element -> Element) -> @count:Nat -> @state:State<&1, &1, Reader, Array<Element>, Context> -> State<&1, &1, Reader, Array<Element>, Context>

template visit_fold_value source · line 206 · raw

@-Reader:Type -> @-Element:Data -> @-Accumulator:Data -> @-Context:Data -> @-combine:(@_:Accumulator -> @_:Element -> Accumulator) -> @position:U32 -> @accumulator:Accumulator -> @result:Pair(Reader, Visited<Context, Element>) -> State<&1, &2, Reader, Accumulator, Context>

template visit_fold_step source · line 211 · raw

@-Reader:Type -> @-Element:Data -> @-Accumulator:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> Pair(Reader, Visited<Context, Element>)) -> @-combine:(@_:Accumulator -> @_:Element -> Accumulator) -> @state:State<&1, &2, Reader, Accumulator, Context> -> State<&1, &2, Reader, Accumulator, Context>

template visit_fold source · line 216 · raw

@-Reader:Type -> @-Element:Data -> @-Accumulator:Data -> @-Context:Data -> @-read:(@_:Reader -> @_:Context -> Pair(Reader, Visited<Context, Element>)) -> @-combine:(@_:Accumulator -> @_:Element -> Accumulator) -> @count:Nat -> @state:State<&1, &2, Reader, Accumulator, Context> -> State<&1, &2, Reader, Accumulator, Context>