Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. --fileName: ex1.hs
  2.  
  3. module ex1 where
  4.  
  5. import Prelude hiding (gcd)
  6.  
  7. gcd :: Int -> (Int -> Int)
  8. gcd x y
  9. --if y=0 then the gcd is the value of x
  10. | y ==0 = x
  11. --if x=0 then the gcd is y
  12. | x ==0 = y
  13. --Apply the Euc. Alg recursively using (2*smaller#) and (larger#-2*smaller#)
  14. | x > y = gcd (2*y) (x-(2*y))
  15. --Otherwise y>= x
  16. |otherwise = gcd (2*x) (y-(2*x))
  17.  
  18. {-
  19. I typed ':r' in ghci and got the following compiler error:
  20.  
  21. *Main> :r
  22.  
  23. ex1.hs:1:8: error: parse error on input `ex1'
  24. |
  25. 1 | module ex1 where
  26. | ^^^
  27. Failed, one module loaded.
  28.  
  29. <interactive>:1:1: error:
  30. Could not find module `Main'
  31. Use -v to see a list of the files searched for.
  32. -}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement