Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. data Range = Range {
  2. from :: Int,
  3. to :: Int
  4. } deriving Ord
  5.  
  6. instance Eq Range where
  7. a == b = fromInclusive a == fromInclusive b && toExclusive a == toExclusive b
  8.  
  9. fromInclusive :: Range -> Int
  10. fromInclusive (Range a _) = a
  11.  
  12. toExclusive :: Range -> Int
  13. toExclusive (Range _ a) = a
  14.  
  15. myRange = Range 3 10
  16. yourRange = Range 3 9
  17.  
  18. isInRange :: Range -> Int -> Bool
  19. isInRange (Range a b) c
  20. | c >= a && c < b = True
  21. | otherwise = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement