Function clamp

Clamps a value between min and max.