def clamp

bend-collections-laws-crypto@1.0.0.0 · src/math/generic.bend:93

import bend-collections-laws-crypto@1.0.0.0/src/math/generic.bend as Generic
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/num.bend as N

93# min(max(x, lo), hi); hi < lo is a Domain error
94def clamp(~T: Data, ~op: N.Op<T> -> T, ~test: N.Test<T> -> Bool, +x: T, +lo: T, +hi: T) -> Result<&2, &2, N.NumError, T>:
95  clamp_ok(~T, ~op, ~test, x, lo, hi, test(N.Lt{hi, lo}))

Uses (6)

Used by (2)