def to_list.go
import lawful-bytes@0.1.1.0/bytes.bend as Bytesimport Base
import lawful-bytes@0.1.1.0/defs.bend as D
178# n more bytes put in front of acc, from byte j down; r holds byte j. A tail
179# call, so the loop runs in constant stack.
180def to_list.go(n: Nat, r: D.Bytes & U32, +j: U32, acc: List<&2, U32>) -> D.Bytes & List<&2, U32>:
181 match n:
182 case 0n:
183 (b, x) = r
184 (b, acc)
185 case 1n+m:
186 (b, +x) = r
187 to_list.go(m, at(b, (j - 1 : U32)), (j - 1 : U32), Con{x, acc})