]> gitweb.factorcode.org Git - factor.git/commitdiff
ranges: fix exclusive ranges for float, ratio, etc.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 25 Oct 2023 18:35:05 +0000 (11:35 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 25 Oct 2023 18:35:05 +0000 (11:35 -0700)
core/ranges/ranges-tests.factor
core/ranges/ranges.factor

index 11ba2741d1f405117b7d86157dad6125d9d11517..e83ff8da170830f428639b4bb0d1b380ca4e54e8 100644 (file)
@@ -96,4 +96,7 @@ USING: arrays kernel math ranges sequences sets tools.test ;
 
 { t } [ 3 10 4 <range> 1 10 2 <range> subset? ] unit-test
 { t } [ 1 0 1 <range> 10 2 1 <range> subset? ] unit-test
-{ f } [ 1 10 2 <range> 3 10 4 <range> subset? ] unit-test 
+{ f } [ 1 10 2 <range> 3 10 4 <range> subset? ] unit-test
+
+{ { 1.5 2.5 3.5 } } [ 1.5 3.7 [a..b) >array ] unit-test
+{ { 1+1/2 2+1/2 3+1/2 } } [ 3/2 37/10 [a..b) >array ] unit-test
index da78e6fcfef11756e4ef801ea23284b083868c53..45668c39aebd02918d53242ebc457084c03c7ca4 100644 (file)
@@ -49,7 +49,8 @@ M: range maximum
 
 : (a.. ( a b step -- a' b' step ) dup [ + ] curry 2dip ; inline
 
-: ..b) ( a b step -- a' b' step ) dup [ - ] curry dip ; inline
+: ..b) ( a b step -- a' b' step )
+    2over - over mod zero? [ dup [ - ] curry dip ] when ; inline
 
 PRIVATE>