Bendtorch.pt_store: def of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/main.bend as Bendtorch Lines 3398-3408 of bendtorch@1.3.0.0/main.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/main.bend&start_line=3398&end_line=3408 import Base # the tree's cells into xs from off def pt_store(t: PTree, xs: Array, +off: U32) -> PTA: match t: case PNew{+v16}: PTA{PNew{v16}, Array.set(F32, Array.set(F32, xs, off, ph_u2f(0)), (off + 1 : U32), ph_u2f(ph_bool(v16))), (off + 2 : U32)} case PLeaf{+n, m, v}: pts_m(n, v, (off + 2 : U32), words_out(U32.to_nat(ph_hw(n)), 0, (off + 2 : U32), Array.get(U32, m, 0), Array.set(F32, Array.set(F32, xs, off, ph_u2f(2)), (off + 1 : U32), ph_u2f(n)))) case PLeafV{+n, m, v}: ptsv_m(n, v, (off + 2 : U32), words_out(U32.to_nat(ph_hw(n)), 0, (off + 2 : U32), Array.get(U32, m, 0), Array.set(F32, Array.set(F32, xs, off, ph_u2f(3)), (off + 1 : U32), ph_u2f(n)))) case PNode{a, b}: pta_then(pt_store(a, Array.set(F32, xs, off, ph_u2f(1)), (off + 1 : U32)), ta => xs2 => off2 => pta_node(ta, pt_store(b, xs2, off2))) Uses (17): 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=Array.set https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=PTA https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=PTree https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=ph_bool https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=ph_hw https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=ph_u2f https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=pta_node https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=pta_then https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=pts_m https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=ptsv_m https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=words_out