clamp

clamp(x, lo, hi)

Return x if lo <= x <= hi. If x < lo, return lo. If x > hi, return hi. Arguments are promoted to a common type. Operates elementwise over x if it is an array.

Examples

julia> clamp(4,5,3)
3
julia> clamp(4,5,7)
5
julia> clamp(2,1,4)
2

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: