4 ms·
In Factor: : clamp ( x min max -- y ) [ max ] dip min ; inline https://docs.factorcode.org/content/word-clamp,math.order.html https://docs.factorcode.org/
by gre 6y ago
In Factor:
: clamp ( x min max -- y ) [ max ] dip min ; inline
https://docs.factorcode.org/content/word-clamp,math.order.html https://docs.factorcode.org/content/word-clamp,math.order.ht...
- cjallen88 6y agoFor casual readers, `dip` pops the top of the stack, executes a quotation, then pushes the top of the stack back on. So this pops the max value off the stack, applies the quoted `max` word to the x and min stack values, then pops the max value back on the stack and applies the `min` word to the result and the max.