aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2017-07-29 10:26:14 -0400
committerEduardo Julian2017-07-29 10:26:14 -0400
commite05d0ab95cc4223824d5faffe1b7fe552127e73f (patch)
tree120ec8a0141954bb86e59eea893d9e7f34626858 /stdlib/source
parentdecf602f5b8a64381cd90b5dbb6fe067e2618e46 (diff)
- Small improvement to overlap testing for intervals.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/interval.lux32
1 files changed, 16 insertions, 16 deletions
diff --git a/stdlib/source/lux/control/interval.lux b/stdlib/source/lux/control/interval.lux
index 95a23c378..16a78e282 100644
--- a/stdlib/source/lux/control/interval.lux
+++ b/stdlib/source/lux/control/interval.lux
@@ -163,22 +163,22 @@
(def: #export (overlaps? reference sample)
(All [a] (-> (Interval a) (Interval a) Bool))
(let [(^open) reference]
- (cond (singleton? sample)
- false
+ (and (not (:: Eq<Interval> = reference sample))
+ (cond (singleton? sample)
+ false
- (singleton? reference)
- (and (>= (:: sample bottom) (:: reference bottom))
- (<= (:: sample top) (:: reference top)))
+ (singleton? reference)
+ (nested? sample reference)
- (or (and (inner? sample) (outer? reference))
- (and (outer? sample) (inner? reference)))
- (or (>= (:: reference bottom) (:: sample top))
- (<= (:: reference top) (:: sample bottom)))
-
- (inner? sample)
- (and (not (:: Eq<Interval> = reference sample))
- (inner? (intersection reference sample)))
+ (or (and (inner? sample) (outer? reference))
+ (and (outer? sample) (inner? reference)))
+ (or (>= (:: reference bottom) (:: sample top))
+ (<= (:: reference top) (:: sample bottom)))
+
+ ## both inner
+ (inner? sample)
+ (inner? (intersection reference sample))
- ## (outer? sample)
- (not (:: Eq<Interval> = reference sample))
- )))
+ ## both outer
+ (not (nested? reference sample))
+ ))))