Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data Range = Range {
- from :: Int,
- to :: Int
- } deriving Ord
- instance Eq Range where
- a == b = fromInclusive a == fromInclusive b && toExclusive a == toExclusive b
- fromInclusive :: Range -> Int
- fromInclusive (Range a _) = a
- toExclusive :: Range -> Int
- toExclusive (Range _ a) = a
- myRange = Range 3 10
- yourRange = Range 3 9
- isInRange :: Range -> Int -> Bool
- isInRange (Range a b) c
- | c >= a && c < b = True
- | otherwise = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement