Advertisement
Guest User

haskell3

a guest
Oct 10th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Homework2 where
  2.     isSmallPrime :: Int -> Bool
  3.     isSmallPrime x = x `elem` [2,3,5,7]
  4.    
  5.     equivalent :: Bool -> Bool -> Bool
  6.     equivalent True  True  = True
  7.     equivalent False False = True
  8.     equivalent _     _     = False
  9.  
  10.     implies :: Bool -> Bool -> Bool
  11.     implies True False = False
  12.     implies _     _     = True
  13.  
  14.     invertO :: (Int, Int) -> (Int, Int)
  15.     invertO (a, b) = (-a, -b)
  16.  
  17.     isOnNegId :: (Int, Int) -> Bool
  18.     isOnNegId (a, b) = (b == -a)
  19.  
  20.     add :: (Int, Int) -> (Int, Int) -> (Int, Int)
  21.     add (a1, b1) (a2, b2) = ((a1*b2)+(a2*b1), (b1*b2))
  22.  
  23.     multiply :: (Int, Int) -> (Int, Int) -> (Int, Int)
  24.     multiply (a1, b1) (a2, b2) = ((a1*a2), (b1*b2))
  25.    
  26.     divide :: (Int, Int) -> (Int, Int) -> (Int, Int)
  27.     divide (a1, b1) (a2, b2) = ((a1*b2), (a2*b1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement