From 05f89b991dfeaf87ff274e55ab095b4409addf3c Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Fri, 4 Nov 2016 22:32:19 +0330 Subject: [PATCH] fix: negation on negative number --- src/Data/MathExpr.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/MathExpr.hs b/src/Data/MathExpr.hs index 99f061a..84ddaf5 100644 --- a/src/Data/MathExpr.hs +++ b/src/Data/MathExpr.hs @@ -81,6 +81,7 @@ module Data.MathExpr -- negative numbers come in the form ["num", "-"] helper [] [o] = read o helper [n, "-"] [] = negate . read $ n + helper ["-"] [n] = negate . read $ n helper (c:cs) os | c == "-" && length os < 2 = let result :: Double = negate . read . head $ cs