Add exponent operator
This commit is contained in:
parent
34fb07223b
commit
8d2c15b5ff
@ -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
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user