Fix NaN handling in math.intervals
parent
9d24828604
commit
ed7ad146d8
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2007 Slava Pestov.
|
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
! Based on Slate's src/unfinished/interval.slate by Brian Rice.
|
! Based on Slate's src/unfinished/interval.slate by Brian Rice.
|
||||||
USING: accessors kernel sequences arrays math math.order
|
USING: accessors kernel sequences arrays math math.order
|
||||||
|
@ -76,9 +76,11 @@ TUPLE: interval { from read-only } { to read-only } ;
|
||||||
[ from>> ] [ to>> ] bi ;
|
[ from>> ] [ to>> ] bi ;
|
||||||
|
|
||||||
: points>interval ( seq -- interval )
|
: points>interval ( seq -- interval )
|
||||||
dup first
|
dup [ first fp-nan? ] contains? [ drop [-inf,inf] ] [
|
||||||
[ [ endpoint-min ] reduce ] 2keep
|
dup first
|
||||||
[ endpoint-max ] reduce <interval> ;
|
[ [ endpoint-min ] reduce ] 2keep
|
||||||
|
[ endpoint-max ] reduce <interval>
|
||||||
|
] if ;
|
||||||
|
|
||||||
: (interval-op) ( p1 p2 quot -- p3 )
|
: (interval-op) ( p1 p2 quot -- p3 )
|
||||||
[ [ first ] [ first ] [ ] tri* call ]
|
[ [ first ] [ first ] [ ] tri* call ]
|
||||||
|
|
Loading…
Reference in New Issue