def clamp
import bend-collections-laws-math@1.0.0.0/src/math/generic.bend as Genericimport Base
import bend-collections-laws-math@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}))