clamp ( x min max -- y )
Factor documentation > Factor handbook > The language > Objects > Linear order protocol
Prev:max ( obj1 obj2 -- obj )
Next:Linear order example


Vocabulary
math.order

Inputs and outputs
xan object
minan object
maxan object
yan object


Word description
Outputs x if contained in the interval [min,max] or else outputs one of the endpoints.

Definition
USING: kernel ;

IN: math.order

: clamp ( x min max -- y ) [ max ] dip min ; inline