Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. module Q24 where
  2.  
  3. import Q22
  4. import Q23
  5.  
  6. diffSelect :: Int -> Int -> [Int]
  7. diffSelect numRandomElements numElements = case (diffSelectTest numRandomElements numElements) of Left result -> result
  8. Right message -> error message
  9.  
  10. diffSelectTest :: Int -> Int -> Either [Int] String
  11. diffSelectTest numRandomElements numElements =
  12. let
  13. check :: Int -> Int -> Either [Int] String
  14. check numRandomElements numElements
  15. | numRandomElements < 1 = Right "Selecting less than one element is not supported"
  16. | numRandomElements > numElements = Right "Selecting more than one numElements is not supported"
  17. | otherwise = Left (diffSelectTest' numRandomElements numElements)
  18.  
  19. diffSelectTest' :: Int -> Int -> [Int]
  20. diffSelectTest' numRandomElements numElements = rndSelect (range 1 numElements) numRandomElements
  21. in
  22. check numRandomElements numElements
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement