Created
March 25, 2011 22:11
-
-
Save Dykam/887739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Range | |
constructor: (@ranges...) -> | |
@rangePoints = (Array.prototype.concat (Range.fixRanges @ranges)...).sort() | |
@ranges = ([start, @rangePoints[i + 1]] for start, i in @rangePoints by 2) | |
intersect: (ranges...) -> | |
new Range @rangePoints.concat (Range.fixRanges ranges)... | |
@fixRanges: (ranges) -> range.rangePoints or range for range in ranges |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment