JoelSjogren

Untitled

Jul 13th, 2017
324
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- module.hs
  2.  
  3. module MyModule where
  4.  
  5. once :: (a -> a) -> (a -> a)
  6. once = \x -> x
  7.  
  8. twice :: (a -> a) -> (a -> a)
  9. twice f x = f (f x)
  10.  
  11. thrice :: (a -> a) -> (a -> a)
  12. thrice f x = f (f (f x))
  13.  
  14. four_times :: (a -> a) -> (a -> a)
  15. four_times f = twice (twice f)
  16.  
  17.  
  18.  
  19. -- ch4.hs
  20.  
  21. module Chapter4 where
  22. import MyModule
  23.  
  24. minus2 :: Num a => a -> a
  25. minus2 x = x-2
  26.  
  27. minus6 = thrice minus2
  28.  
  29. plus3 :: Num a => a -> a
  30. plus3 = (+3)
  31.  
  32. same :: Num a => a -> a
  33. same = minus6.plus3.plus3
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment