Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Expr =
- |Const of int
- |Var of string
- |Add of Expr * Expr
- |Sub of Expr * Expr
- |Mul of Expr * Expr
- |Div of Expr * Expr
- let rec calc expr =
- match expr with
- |Const a -> a
- |Add(a, b) -> calc a + calc b
- |Sub(a, b) -> calc a - calc b
- |Mul(a, b) -> calc a * calc b
- |Div(a, b) -> calc a / calc b
- calc (Add((Const 1)(Const 2)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement