Hi Doug, This clamp functionality is already present in math.ranges as clamp-to-range:
( scratchpad ) 100 -20 0 [a,b] clamp-to-range . 0 ( scratchpad ) 100 20 0 [a,b] clamp-to-range . 20 ( scratchpad ) 100 120 0 [a,b] clamp-to-range . 100 Not as clean obviously, but more general. Maybe clamp-to-range can be simplified from: : clamp-to-range ( n range -- n ) [ range-min max ] [ range-max min ] bi ; to: : clamp-to-range ( n range -- n ) [ range-min ] [ range-max ] bi clamp ; Alex 2009/5/26 Doug Coleman <doug.cole...@gmail.com> > Hi everyone, > > I added a ``clamp'' word to math.order for clamping a value to an > interval. Writing min/max by hand is error-prone and the pattern > comes up fairly often. > > ( scratchpad ) -20 0 100 clamp . > 0 > ( scratchpad ) 20 0 100 clamp . > 20 > ( scratchpad ) 120 0 100 clamp . > 100 > > The word 'at-default' has been removed because it was only used in a > few places, it's just ``?at drop'' and because it had no docs. > > Someday soon ``peek'' will be renamed to ``last'' since not all > sequences should be thought of as stacks and because first/last is > more congruent than first/peek. > > As always, if anyone notices inconsistencies or patterns for which a > word should exist, let us know. > > Happy factoring, > Doug > > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. > Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian > Group, R/GA, & Big Spaceship. http://www.creativitycat.com > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk >
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk