Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Lab1 where
- 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 then
- b
- else
- a
- solve2 :: Double -> Double -> (Bool, Double)
- solve2 a b = if (a == 0 && b /= 0) then
- (False, 0.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) (x3, y3) (x4, y4) = if ((y2 - y1) * (x4 - x3)) - ((y4 - y3) * (x2 - x1)) == 0 then
- True
- else
- False
- distance :: (Double, Double) -> (Double, Double) -> Double
- distance (x1, y1) (x2, y2) = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
- isIncluded :: (Double, (Double, Double)) -> (Double, (Double, Double)) -> Bool
- isIncluded (r1, (x1, y1)) (r2, (x2, y2)) = if distance (x1, y1) (x2, y2) + r2 <= r1 then
- True
- else
- False
- isRectangel :: (Double, Double) -> (Double, Double) -> (Double, Double) -> Bool
- isRectangel (x1, y1) (x2, y2) (x3, y3) = if ((distance (x1, y1) (x2, y2))^2 == (distance (x1, y1) (x3, y3))^2 + (distance (x2, y2) (x3, y3))^2) ||
- ((distance (x1, y1) (x3, y3))^2 == (distance (x1, y1) (x2, y2))^2 + (distance (x2, y2) (x3, y3))^2) ||
- ((distance (x2, y2) (x3, y3))^2 == (distance (x1, y1) (x3, y3))^2 + (distance (x1, y1) (x2, y2))^2)
- 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
- isTriangle :: (Double, Double) -> (Double, Double) -> (Double, Double) -> Bool
- isTriangle (x1, y1) (x2, y2) (x3, y3) = if(distance (x1, y1) (x2, y2) < (distance (x1, y1) (x3, y3) + distance (x2, y2) (x3, y3)) &&
- distance (x1, y1) (x3, y3) < (distance (x1, y1) (x2, y2) + distance (x2, y2) (x3, y3)) &&
- distance (x2, y2) (x3, y3) < (distance (x1, y1) (x2, y2) + distance (x1, y1) (x3, y3)))
- then
- True
- else
- False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement