]> gitweb.factorcode.org Git - factor.git/blob - extra/math/compare/compare.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / extra / math / compare / compare.factor
1 ! Copyright (C) 2008 John Benediktsson.
2 ! See http://factorcode.org/license.txt for BSD license
3 USING: math math.order kernel ;
4 IN: math.compare
5
6 : absmin ( a b -- x )
7     [ [ abs ] bi@ < ] most ;
8
9 : absmax ( a b -- x )
10     [ [ abs ] bi@ > ] most ;
11
12 : posmax ( a b -- x )
13     0 max max ;
14
15 : negmin ( a b -- x )
16     0 min min ;
17
18 : max-by ( obj1 obj2 quot: ( obj -- n ) -- obj1/obj2 )
19     [ bi@ dupd max = ] curry most ; inline
20
21 : min-by ( obj1 obj2 quot: ( obj -- n ) -- obj1/obj2 )
22     [ bi@ dupd min = ] curry most ; inline