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