Commit ebce00a0 authored by Philipp Meyer's avatar Philipp Meyer

Remove division and multiplication operators

parent 2deed1ec
......@@ -84,7 +84,7 @@ prefix name fun = Prefix ( reservedOp name *> return fun )
termOperatorTable :: [[Operator String () Identity (Term String)]]
termOperatorTable =
[ [ prefix "-" Minus ]
, [ binary "*" (:*:) AssocLeft, binary "/" (:/:) AssocLeft, binary "%" (:%:) AssocLeft ]
, [ binary "*" (:*:) AssocLeft ]
, [ binary "+" (:+:) AssocLeft, binary "-" (:-:) AssocLeft ]
]
......
......@@ -22,8 +22,6 @@ data Term a =
| Term a :+: Term a
| Term a :-: Term a
| Term a :*: Term a
| Term a :/: Term a -- integer division truncated toward negative infinity
| Term a :%: Term a -- integer modulos, satisfying (x / y)*y + (x % y) = x
deriving (Eq)
instance (Show a) => Show (Term a) where
......@@ -33,8 +31,6 @@ instance (Show a) => Show (Term a) where
show (t :+: u) = "(" ++ show t ++ " + " ++ show u ++ ")"
show (t :-: u) = "(" ++ show t ++ " - " ++ show u ++ ")"
show (t :*: u) = show t ++ " * " ++ show u
show (t :/: u) = show t ++ " / " ++ show u
show (t :%: u) = show t ++ " % " ++ show u
instance Functor Term where
fmap f (Var x) = Var (f x)
......@@ -43,8 +39,6 @@ instance Functor Term where
fmap f (t :+: u) = fmap f t :+: fmap f u
fmap f (t :-: u) = fmap f t :-: fmap f u
fmap f (t :*: u) = fmap f t :*: fmap f u
fmap f (t :/: u) = fmap f t :/: fmap f u
fmap f (t :%: u) = fmap f t :%: fmap f u
data Op = Gt | Ge | Eq | Ne | Le | Lt | ModEq Integer | ModNe Integer deriving (Eq)
......
......@@ -15,8 +15,6 @@ evaluateTerm (Minus t) m = - evaluateTerm t m
evaluateTerm (t :+: u) m = evaluateTerm t m + evaluateTerm u m
evaluateTerm (t :-: u) m = evaluateTerm t m - evaluateTerm u m
evaluateTerm (t :*: u) m = evaluateTerm t m * evaluateTerm u m
evaluateTerm (t :/: u) m = (evaluateTerm t m) `sDiv` (evaluateTerm u m)
evaluateTerm (t :%: u) m = (evaluateTerm t m) `sMod` (evaluateTerm u m)
opToFunction :: Op -> SInteger -> SInteger -> SBool
opToFunction Gt = (.>)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment