def digit_on

bend-collections-laws-math@1.0.0.0 · spec/math/fixed.bend:229

import bend-collections-laws-math@1.0.0.0/spec/math/fixed.bend as Fixed
import Base
import bend-collections-laws-math@1.0.0.0/spec/lib/common.bend as C

229# the value of exactly k base-256 digits, least significant first; None
230# for another length or a digit of 256 or more
231def digit_on(r: Maybe<&2, Nat>, ok: Bool, +x: Nat) -> Maybe<&2, Nat>:
232  match r:
233    case Some{+v}:
234      match ok:
235        case True{}:
236          Some{Nat.add(x, C.shift(8n, v))}
237        case False{}:
238          None{}
239    case None{}:
240      None{}

Uses (5)

Used by (9)