From e05d0ab95cc4223824d5faffe1b7fe552127e73f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 29 Jul 2017 10:26:14 -0400 Subject: - Small improvement to overlap testing for intervals. --- stdlib/source/lux/control/interval.lux | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'stdlib') 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 = 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 = 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 = reference sample)) - ))) + ## both outer + (not (nested? reference sample)) + )))) -- cgit v1.2.3