Competition Language | |
Constrain | How to Use |
The constrain function simply takes the input value and ensures it is between the other two values. If the input is outside of those values, it will output the closest value in the range (one of the boundaries). Otherwise, it will output the input. This was programmed so that the two boundaries do not need to put their values in any specific order. If the greater of the two is put first, it does not change how it works.
To use the constrain function, you simple type in one input value, and two bounds. If the input value is inside the bounds, it will just be returned. Otherwise, the constrain function will return the bound it is closest to. You do not need to place the bounds in numerical order.