factor/extra/math/compare/compare.factor

23 lines
386 B
Factor
Raw Normal View History

2008-09-23 17:50:28 -04:00
! Copyright (C) 2008 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
2008-09-23 17:36:21 -04:00
USING: math math.order kernel ;
IN: math.compare
: absmin ( a b -- x )
[ [ abs ] dip abs < ] 2keep ? ;
: absmax ( a b -- x )
[ [ abs ] dip abs > ] 2keep ? ;
: posmax ( a b -- x )
0 max max ;
: negmin ( a b -- x )
0 min min ;
: clamp ( a value b -- x )
min max ;