From 8d2c15b5ff5e2fa33f7eabe0774de33fbc97db8e Mon Sep 17 00:00:00 2001 From: osmarks Date: Thu, 17 Aug 2017 22:36:53 +0100 Subject: [PATCH] Add exponent operator --- src/Expr.elm | 2 ++ src/Main.elm | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Expr.elm b/src/Expr.elm index f9f9f9d..49bfd0b 100644 --- a/src/Expr.elm +++ b/src/Expr.elm @@ -8,6 +8,7 @@ type Op | Subtract | Multiply | Divide + | Exponent type Expr = Num Float @@ -29,6 +30,7 @@ op = <|> stringIs "-" Subtract <|> stringIs "*" Multiply <|> stringIs "/" Divide + <|> stringIs "^" Exponent |> map Op group : Parser () Expr diff --git a/src/Main.elm b/src/Main.elm index 088d03e..fed250d 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -84,6 +84,7 @@ evalRec expr s = Subtract -> binOp (-) s Multiply -> binOp (*) s Divide -> binOp (/) s + Exponent -> binOp (^) s eval : Expr -> Result (List String) (List Float) eval e =