def nth

bend-collections@1.0.0.0 · spec/crypto/sha.bend:79

import bend-collections@1.0.0.0/spec/crypto/sha.bend as Sha
import Base

79# In reverse history, index j denotes W[t-1-j]. Only valid indices are
80# reached for the actual 16-word input blocks; default zero makes nth total.
81def nth(history: List<&2, U32>, index: Nat) -> U32:
82  match history index:
83    case Nil{} _:
84      0
85    case w <> rest 0n:
86      w
87    case w <> rest 1n+p:
88      nth(rest, p)

Uses (3)

Used by (3)