Advertisement
KillianMills

exercise2.hs

Oct 9th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff :: Int -> Int -> Int
  2. diff x y = abs (x-y)
  3.  
  4. triangleArea :: Float -> Float -> Float -> Float
  5. triangleArea a b c =
  6.              let s =(a + b + c) / 2
  7.              in sqrt(s*(s-a)*(s-b)*(s-c))
  8.              
  9. isSum :: Int -> Int -> Int -> Bool
  10. isSum a b c =
  11.             if ( a + b == c || a + c == b ||  b + c == a )
  12.                 then True
  13.                     else False
  14.                    
  15. ex3 :: Float -> Float -> Float -> Float
  16. ex3 a b c =
  17.         if ( a + b < c || a + c < b ||  b + c < a )
  18.             then error "Idiot alert, not a triangle"
  19.                 else
  20.                     let s =(a + b + c) / 2
  21.                     in sqrt(s*(s-a)*(s-b)*(s-c))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement