def chunk_bytes
import bendtorch@1.3.0.0/main.bend as Bendtorchimport Base
3596# the bytes of xs[i - k + 1 .. i] onto acc, built from the last number back (no reverse)
3597def chunk_bytes(k: Nat, +i: U32, rx: Array<F32> & F32, acc: List<&2, U32>) -> Array<F32> & List<&2, U32>:
3598 match k rx:
3599 case 0n Tuple{a, v}: Tuple{a, acc}
3600 case 1n+q Tuple{a, v}:
3601 +u = bits(v)
3602 chunk_bytes(q, U32.sub(i, 1), Array.get(F32, a, U32.sub(i, 1)), byte_of(u, 0n) <> byte_of(u, 8n) <> byte_of(u, 16n) <> byte_of(u, 24n) <> acc)