Add exponent operator

This commit is contained in:
osmarks 2017-08-17 22:36:53 +01:00
parent 34fb07223b
commit 8d2c15b5ff
2 changed files with 3 additions and 0 deletions

View File

@ -8,6 +8,7 @@ type Op
| Subtract | Subtract
| Multiply | Multiply
| Divide | Divide
| Exponent
type Expr type Expr
= Num Float = Num Float
@ -29,6 +30,7 @@ op =
<|> stringIs "-" Subtract <|> stringIs "-" Subtract
<|> stringIs "*" Multiply <|> stringIs "*" Multiply
<|> stringIs "/" Divide <|> stringIs "/" Divide
<|> stringIs "^" Exponent
|> map Op |> map Op
group : Parser () Expr group : Parser () Expr

View File

@ -84,6 +84,7 @@ evalRec expr s =
Subtract -> binOp (-) s Subtract -> binOp (-) s
Multiply -> binOp (*) s Multiply -> binOp (*) s
Divide -> binOp (/) s Divide -> binOp (/) s
Exponent -> binOp (^) s
eval : Expr -> Result (List String) (List Float) eval : Expr -> Result (List String) (List Float)
eval e = eval e =