Arithmetic evaluation: Difference between revisions
Content deleted Content added
→{{header|Common Lisp}}: Rewrite using more natural token representation, use of backquote, translation from infix to prefix and direct eval. More syntax error checking cases added. |
|||
Line 1,841: | Line 1,841: | ||
| Quot of expression * expression (* e1 / e2 *) |
| Quot of expression * expression (* e1 / e2 *) |
||
let rec eval |
let rec eval = function |
||
match expr with |
|||
| Const c -> c |
| Const c -> c |
||
| Sum (f, g) -> eval f +. eval g |
| Sum (f, g) -> eval f +. eval g |