diff --git a/core/math/intervals/intervals.factor b/core/math/intervals/intervals.factor index 8afbee3478..6e50f42726 100755 --- a/core/math/intervals/intervals.factor +++ b/core/math/intervals/intervals.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007 Slava Pestov. +! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. ! Based on Slate's src/unfinished/interval.slate by Brian Rice. USING: accessors kernel sequences arrays math math.order @@ -76,9 +76,11 @@ TUPLE: interval { from read-only } { to read-only } ; [ from>> ] [ to>> ] bi ; : points>interval ( seq -- interval ) - dup first - [ [ endpoint-min ] reduce ] 2keep - [ endpoint-max ] reduce ; + dup [ first fp-nan? ] contains? [ drop [-inf,inf] ] [ + dup first + [ [ endpoint-min ] reduce ] 2keep + [ endpoint-max ] reduce + ] if ; : (interval-op) ( p1 p2 quot -- p3 ) [ [ first ] [ first ] [ ] tri* call ]