Robert Fisher

Just thinking out loud

Do ranges overlap

If you register and log in you can add comments to my pages. If viewing the main blog page, click the # underneath an entry to comment on it.

To determine if two ranges overlap:

  • Lispy: (not (or (< end1 start2) (< end2 start1)))
  • Cish: !((end1 < start2) || (end2 < start1))

Assumptions:

  • The ranges are inclusive
  • (and (≤ start1 end1) (≤ start2 end2))