aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/abstract/interval.lux
diff options
context:
space:
mode:
authorEduardo Julian2020-03-18 21:39:33 -0400
committerEduardo Julian2020-03-18 21:39:33 -0400
commit409deaa8f8a9727cf42762c8ac8ebe5b2766a04b (patch)
tree0deba59f851582f74c0285abe168f36ed7dad79d /stdlib/source/lux/abstract/interval.lux
parent30801bcf8fbb1be7ae8f193edfa71e6c4909a4c3 (diff)
Test for order + fixes for interval.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/abstract/interval.lux28
1 files changed, 14 insertions, 14 deletions
diff --git a/stdlib/source/lux/abstract/interval.lux b/stdlib/source/lux/abstract/interval.lux
index 17e749804..46fe020e1 100644
--- a/stdlib/source/lux/abstract/interval.lux
+++ b/stdlib/source/lux/abstract/interval.lux
@@ -102,12 +102,23 @@
(All [a] (-> (Interval a) (Interval a) Bit))
(precedes? sample reference))
+(template [<name> <comp>]
+ [(def: #export (<name> reference sample)
+ (All [a] (-> a (Interval a) Bit))
+ (let [(^open ",@.") sample]
+ (and (<comp> reference ,@bottom)
+ (<comp> reference ,@top))))]
+
+ [before? ,@<]
+ [after? (order.> ,@&order)]
+ )
+
(def: #export (meets? reference sample)
(All [a] (-> (Interval a) (Interval a) Bit))
(let [(^open ",@.") reference
- limit (:: reference ,@bottom)]
- (and (order.<= ,@&order limit (:: sample ,@bottom))
- (,@= limit (:: sample ,@top)))))
+ limit (:: reference bottom)]
+ (and (,@= limit (:: sample top))
+ (order.<= ,@&order limit (:: sample bottom)))))
(def: #export (touches? reference sample)
(All [a] (-> (Interval a) (Interval a) Bit))
@@ -128,17 +139,6 @@
[finishes? ,@top order.>= ,@bottom]
)
-(template [<name> <comp>]
- [(def: #export (<name> reference sample)
- (All [a] (-> a (Interval a) Bit))
- (let [(^open ",@.") sample]
- (and (<comp> reference ,@bottom)
- (<comp> reference ,@top))))]
-
- [before? ,@<]
- [after? (order.> ,@&order)]
- )
-
(structure: #export equivalence (All [a] (Equivalence (Interval a)))
(def: (= reference sample)
(let [(^open ",@.") reference]