From 2dbcd7c9eb6dccecb460712fd176fb0a6402cc72 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Fri, 4 Nov 2016 22:26:49 +0330 Subject: [PATCH] fix: negated number left as the last expression would fail --- mathexpr.cabal | 2 +- src/Data/MathExpr.hs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mathexpr.cabal b/mathexpr.cabal index 2b47539..53e6464 100644 --- a/mathexpr.cabal +++ b/mathexpr.cabal @@ -1,5 +1,5 @@ name: mathexpr -version: 0.2.0.0 +version: 0.2.0.1 synopsis: Parse and evaluate math expressions with variables and functions description: A simple tool to evaluate math expressions as strings with support for custom functions and operators homepage: https://github.com/mdibaiee/mathexpr diff --git a/src/Data/MathExpr.hs b/src/Data/MathExpr.hs index 85a22b3..99f061a 100644 --- a/src/Data/MathExpr.hs +++ b/src/Data/MathExpr.hs @@ -80,6 +80,7 @@ module Data.MathExpr helper :: [String] -> [String] -> Double -- negative numbers come in the form ["num", "-"] helper [] [o] = read o + helper [n, "-"] [] = negate . read $ n helper (c:cs) os | c == "-" && length os < 2 = let result :: Double = negate . read . head $ cs