Imagine an arithmetic expression such as (+ 1 (* 2 (- 3 5))) being thought of as a tree-like structure with numbers at the leaves and operator symbols at the interior nodes like below:
+
/ \
1 *
/ \
2 -
/ \
3 5
each node can be expressed by a three element list: (left-operand operator right-operand)
I am trying to write a function
(make-expr left-op operator right-op)
that produces
(left-op operator right-op)
for example:
(make-expr '(6 * 3) '+ '(5 -2)) => ((6 * 3) + (5 - 2))
Yes, it’s as simple as using the
listfunction.