1 let rec interpret =
2 function
3 | DigitExpression a -> a
4 | ParenthesizedExpression (l, o, r) ->
5 let left = interpret l
6 let right = interpret r
7 match o with
8 | Add -> left + right
9 | Multiply -> left * right
See my last post for an example in C#
No comments:
Post a Comment