Commit 89de289b by Zachary Snow

simplify numeric negation

parent a77347f5
...@@ -164,6 +164,10 @@ readNumber n = ...@@ -164,6 +164,10 @@ readNumber n =
simplify :: Expr -> Expr simplify :: Expr -> Expr
simplify (UniOp LogNot (Number "1")) = Number "0" simplify (UniOp LogNot (Number "1")) = Number "0"
simplify (UniOp LogNot (Number "0")) = Number "1" simplify (UniOp LogNot (Number "0")) = Number "1"
simplify (orig @ (UniOp UniSub (Number n))) =
case readNumber n of
Nothing -> orig
Just x -> Number $ show (-x)
simplify (orig @ (Repeat (Number n) exprs)) = simplify (orig @ (Repeat (Number n) exprs)) =
case readNumber n of case readNumber n of
Nothing -> orig Nothing -> orig
......
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