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
| 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

View File

@ -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 =