Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Lab1 where
- square :: Int->Int
- square x = x*x
- prod :: Int->Int->Int
- prod x y = x*y
- ispositive :: Int->Bool
- ispositive x = if x>0 then True else False
- singnum :: Int->Int
- singnum x = if x>0 then 1 else if x<0 then -1 else 0
- max3 :: Int->Int->Int->Int
- max3 a b c = if a>b && a>c then a else if b>a && b>c then b else c
- sort2 :: Int->Int->(Int,Int)
- sort2 a b = if a > b then (b, a) else (a, b)
- bothTrue :: Bool->Bool->Bool
- bothTrue a b = if a == True then if b == True then True else False else False
- solved :: Double->Double->(Bool,Double)
- solved a b = if ( a == 0 && b /= 0) then (False, 0) else if (a == 0 && b == 0) then (True, 0) else (True, -b/a)
- isParallel :: ((Double, Double), (Double, Double))->((Double, Double), (Double, Double))->Bool
- isParallel (x1, y1) (x2, y2) = if (fst y1 - fst x1) * (snd y2 - snd x2) - ( fst y2 - fst x2) * (fst y1 - snd x1) == 0 then True else False
- isIncluded :: (Double, (Double, Double))->(Double, (Double, Double))->Bool
- isIncluded (r1, (x1, y1)) (r2, (x2, y2)) = if sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2) + r2 <= r1 then True else False
- scalar :: (Double, Double)->(Double, Double)->Bool
- scalar (x1, y1) (x2, y2) = if x1 * x2 + y1 * y2 == 0 then True else False
- isRectangular :: (Double, Double)->(Double, Double)->(Double,Double)->Bool
- isRectangular (x1, y1) (x2, y2) (x3, y3) = if scalar ((x2 - x1), (y2 - y1)) ((x3 - x1), (y3 - y1)) == True || scalar ((x1 - x2), (y1 - y2)) ((x3 - x2), (y3 - y2)) == True || scalar ((x1 - x3), (y1 - y3)) ((x2 - x3), (y2 - y3)) == True then True else False
- isTriangle :: Double->Double->Double->Bool
- isTriangle a b c = if a + b > c && b + c > a && a + c > b then True else False
- isSorted :: Int->Int->Int->Bool
- isSorted a b c = if((a < b && b < c) || (a > b && b > c)) then True else False
Add Comment
Please, Sign In to add comment