Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Matthew Larson Exercise 1.4 10/4/2019
  2.  
  3. -- Hypotenuse.hs
  4. -- | A module for working with triangles.
  5.  
  6.     module Hypotenuse where
  7.  
  8.     -- | Compute the length of the hypotenuse of a triangle from the lengths
  9.     --   of its sides.
  10.     hypotenuse :: Double -> Double -> Double
  11.     hypotenuse a b = sqrt (a^2 + b^2)
  12.  
  13.     -- | Square a number.
  14.  
  15.     square :: Num n => n -> n
  16.     square x = x ^ 2
  17.  
  18.     law_of_cosines :: Double -> Double -> Double -> Double
  19.     law_of_cosines a b gamma = sqrt (a^2 + b^2 - 2*a*b*cos(gamma*pi/180))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement