Guest User

Untitled

a guest
Aug 4th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data Polynomial = Var String                    -- Variables
  2.                 | Const Integer                 -- Constant numbers
  3.                 | Add Polynomial Polynomial     -- Addition
  4.                 | Mul Polynomial Polynomial     -- Multiplication
  5.                
  6. instance Show Polynomial where
  7.     show (Var x) = show x
  8.     show (Const x) = show x
  9.     show (Add x y) = "(" ++ filter (/= '"') (show x) ++ "+" ++ filter (/= '"') (show x) ++ ")"
  10.     show (Mul x y) = "(" ++ filter (/= '"') (show x) ++ "*" ++ filter (/= '"') (show x) ++ ")"
  11.  
  12. instance Eq Polynomial where
  13.     (Polynomial x) == (Polynomial y) =
Add Comment
Please, Sign In to add comment