/proc/clamp(Value, Low, High)
Usage:
clamp(Number, Low, High)
Number: A number.
Low: The lowest number that can be returned.
High: The highest number that can be returned.
clamp(/list/List, Low, High)
List: A list of numbers.
Returns:
null, num, /list: The provided number, kept between the Low and High values.
The original list, with the numeric contents kept between the Low and High values.

Constricts a number between the Low and High values provided. If the number is between those values, it is unchanged. If it exceeds the Low or High values, those will be returned.

world.log << clamp(5, 1, 10) // 5
world.log << clamp(1, 5, 10) // 5
world.log << clamp(15, 1, 10) // 10

When operating on a list, this functions as if clamp() has been run on each entry in the list.

var/my_list = list(1, 2, 3, 4, 5, 6, 7, 8, 9)
for(var/num in clamp(my_list, 1, 5))
    world.log << num // 1, 2, 3, 4, 5, 5, 5, 5, 5
Parity Issue ⚠️
In the OpenDream implementation of DreamMaker, this feature differs in implementation:
A new list will always be returned from the clamp() proc, it does not operate in place