Basic module

clamp

procedureSource

x limited to the range from a to b. Bring a and b in the right order yourself: with a > b the result is a.

clamp :: (x: $T, a: T, b: T) -> T

Parameters

x: $T
a: T
b: T

Returns

T
Example↗
assert(clamp(15, 0, 10) == 10);
assert(clamp(-5, 0, 10) == 0);
assert(clamp(4, 0, 10) == 4);

See also