; Starting writing your own arithmetic DSL in Lisp
; ------------------------------
; The Little Lisper 3rd Edition
; Chapter 7
; Exercise 1
; Common Lisp
; http://t...content-available-to-author-only...r.com/thelittlelisper
; http://t...content-available-to-author-only...t.com/2010/06/little-lisper-chapter-7-shadows.html
; http://t...content-available-to-author-only...t.com/2010/06/little-lisper.html
; ------------------------------
(setf l1 '())
(setf l2 '(3 + (66 6)))
(setf aexp4 5)
; ------------------------------
(defun mk\+exp (aexp1_ aexp2_)
  (cons aexp1_
        (cons '+
              (cons aexp2_ '()))))

(print (mk\+exp 1 2))
;(1 + 2)

(defun mk\*exp (aexp1_ aexp2_)
  (cons aexp1_
        (cons '*
              (cons aexp2_ '()))))

(print (mk\*exp 1 2))
;(1 * 2)

(defun mk\^exp (aexp1_ aexp2_)
  (cons aexp1_
        (cons '^
              (cons aexp2_ '()))))

(print (mk\^exp 1 2))
;(1 ^ 2)

(setf aexp1 (mk\+exp 1 (mk\*exp 3 4)))
(setf aexp2 (mk\+exp (mk\^exp 3 4) 5))
(setf aexp3 (mk\*exp 3 (mk\*exp 4 (mk\*exp 5 6))))
