fit number lb ub &optional mode &key :return-type [Function]

Forces number to lie between the low bound lb and upper bound ub according to mode. If mode is :reflect (the default), then the boundaries "reflect" the value back into the range. Otherwise, mode is :wrap, which returns the remainder of the value modulus the boundary range.The type of the value returned normally depends on the type of the arguments specified to the function. Use :return-type to force the return value to be either float, integer or ratio. float may be specified as a list (float digits) in which case the floating point return value will be rounded to digitnumber of places.

Example:

? (loop for i from -20 to 20 by 5 collect (fit i 0 10))
(0 5 10 5 0 5 10 5 0)

See Also:

expl, rescale


Last Modified: 5-Mar-1998