]> gitweb.factorcode.org Git - factor.git/blob - extra/math/compare/compare.factor
93a8da7cf3a39df182658ed56b8a4932f3353b6a
[factor.git] / extra / math / compare / compare.factor
1 ! Copyright (C) 2008 John Benediktsson.
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: math math.order kernel ;
5
6 IN: math.compare
7
8 : absmin ( a b -- x )
9     [ [ abs ] bi@ < ] 2keep ? ;
10
11 : absmax ( a b -- x )
12     [ [ abs ] bi@ > ] 2keep ? ;
13
14 : posmax ( a b -- x )
15     0 max max ;
16
17 : negmin ( a b -- x )
18     0 min min ;
19
20 : clamp ( value a b -- x )
21     [ max ] [ min ] bi* ;