Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --fileName: ex1.hs
- module ex1 where
- import Prelude hiding (gcd)
- gcd :: Int -> (Int -> Int)
- gcd x y
- --if y=0 then the gcd is the value of x
- | y ==0 = x
- --if x=0 then the gcd is y
- | x ==0 = y
- --Apply the Euc. Alg recursively using (2*smaller#) and (larger#-2*smaller#)
- | x > y = gcd (2*y) (x-(2*y))
- --Otherwise y>= x
- |otherwise = gcd (2*x) (y-(2*x))
- {-
- I typed ':r' in ghci and got the following compiler error:
- *Main> :r
- ex1.hs:1:8: error: parse error on input `ex1'
- |
- 1 | module ex1 where
- | ^^^
- Failed, one module loaded.
- <interactive>:1:1: error:
- Could not find module `Main'
- Use -v to see a list of the files searched for.
- -}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement