def stream_go

bend-collections-laws-math@1.0.0.0 · spec/math/random/chacha8rand.bend:194

import bend-collections-laws-math@1.0.0.0/spec/math/random/chacha8rand.bend as Chacha8rand
import Base
import bend-collections-laws-math@1.0.0.0/src/math/u64.bend as W

194# n outputs: the words left of the current iteration, then the next
195# iterations, each keyed by the last 32 bytes of the one before
196def stream_go(n: Nat, buf: List<&2, W.U64>, +key: List<&2, U32>) -> List<&2, W.U64>:
197  match n buf:
198    case 0n _:
199      []
200    case 1n+p Con{x, rest}:
201      Con{x, stream_go(p, rest, key)}
202    case 1n+p Nil{}:
203      Con{head(words64(output(key))), stream_go(p, tail(words64(output(key))), next_key(key))}

Uses (9)

Used by (2)