; To fully test your "x" version of eval, enter the following exprs at the top
; of the read-xeval-print loop.  To perform interactive testing, type (or
; paste) these expressions individually.  To load these expressions en masse
; from this file, use the program in readfile-xeval-print.l, q.v.  I.e., your
; final hand-in for assignment 6 should be run using readfile-xeval-print.l.
;

(xquote "-- BASIC ATOM TESTS --")
10
"hi"
nil
t
x

(xquote "-- XSETQ TESTS --")
(xsetq x 10)
x
(xsetq x 20)
x
(xsetq x (xsetq y 100))
x
y
(xsetq y (+ 100 100))
(xsetq z (+ x y))
x
y
z

(xquote "-- XDEFUN TESTS --")
(xdefun xprint (x) (print x))
(xdefun f (x y)
    (xprint x) (xsetq x (xquote f)) (g x y) (xprint x) (xprint y))
(xdefun g (x y)
    (xprint x) (xsetq x (xquote g)) (xsetq z 30000)
    (h x y nil) (xprint x) (xprint y))
(xdefun h (x y z)
    (xsetq z (xsetq x (xquote h))) :dump)
(f x y)
x
y
z

(xquote "-- XCOND TESTS --")
(xdefun xeq (x y) (eq x y))
(xcond (()))
(xcond ((xeq 1 1) 1))
(xcond ((xeq 1 1) 1 1 1 10))
(xcond ((xeq 1 2) 1 1 1 x) ((xeq 2 2) 1 1 1 (xquote z)))
(xsetq x 1)
(xsetq y 2)
(xcond ((xeq x y) 1 1 1 x) ((xeq 2 2) 1 1 1 (xquote z)))
(xsetq x 2)
(xcond ((xeq x y) 1 1 1 x) ((xeq 2 2) 1 1 1 (xquote z)))
(xcond ((xsetq w 40) (xprint w)))
w

(xquote "-- ADVANCED TESTS --")
(xdefun xnull (x) (null x))
(xdefun xadd1 (n) (1+ n))
(xdefun xcdr (xsexpr) (cdr xsexpr))
(xdefun xlength (l)
    (xcond ((xnull l) 0)
           (t (xadd1 (xlength (xcdr l))))
    )
)
(xlength (xquote (a b c)))
(xlength (append (xquote (1)) (xquote (2))))