Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Gabe Schoenbach
- -- Exercise 1.1
- -- | A module for working with triangles.
- module Hypotenuse where
- -- | Compute the length of the hypotenuse of a triangle from the lengths of its sides.
- hypotenuse :: Double -> Double -> Double
- hypotenuse a b = sqrt (square a + square b)
- -- | Square a number.
- square :: Num n => n -> n
- square x = x ^ 2
- -- Exercise 1.4
- -- | Change degrees into radians.
- deg_to_rad :: Double -> Double
- deg_to_rad d = d * pi / 180
- -- | Compute the length of one side of a triangle from the lengths of the other two sides a and b and gamma, the angle (in degrees) between a and b.
- law_of_cosines :: Double -> Double -> Double -> Double
- law_of_cosines a b gamma = sqrt (square a + square b - (2 * a * b * cos (deg_to_rad gamma)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement