▲ | atombender 6 hours ago | |
This maps poorly to the mathematical concept of a closed interval [a, b], which can be written a ≤ x ≤ b for a set of x. An interval where a > b is usually a programming error. To ensure only valid intervals are supported at the type system level, the function could perhaps be redefined as:
Of course, you need to deal with the distinction between closed and open intervals. Clamping really only makes sense for closed ones. |