It's trivial and useful:
clamp restricts a number to a range.
clamp val low high = min (max val low) high
Argument order varies, of course. This particular order has the convenient property that if you forget and write
clamp min val max, it still works.
I wanted this function years ago, in an application where I'd written a great many calls to
max, with a number of mistakes because of the counterintuitive usage (
min to impose a maximum,
max a minimum). I almost replaced them with
clamp, but I couldn't think of a good name for it. Then recently I stumbled across it in some language's standard library (I have already forgotten which) and was delighted to finally be able to put a name to the concept; I must have been (so I ashamedly imagine) the only mathematically inclined programmer in the world who didn't know what it was called.