(defun quickCombineEval (x y) (list (eval x) (eval y))) (defmacro sqrPlusOne (x) `(+ (* ,x ,x) ,1)) (defmacro isMore? (toTest &rest todo) `( if ( > ,@todo ,toTest) t nil)) (define-modify-macro removefromlist (y) (lambda (lst y) (remove y lst))) ;just does the above with better notation ;forces local variable to constant just to verify gensym functions (defmacro goodMacro (x) ( let ( ;declare gensyms (z (gensym)) (y (gensym))) `( let ((,z ,x) (,y 25)) (setf ,z (+ (* ,z ,z) 1)) ) ) ) ;Deftests for chapter 1 (deftest justinChap10 () (let ((x 2)) (check ;open check (equal '(20 10) (quickCombineEval '(* 10 2) '(- 20 10))) (= 5 (sqrPlusOne x)) ; check for 10.2 (isMore? 10 (+ 6 5)) ;check for (equal '(5 10) (let ((y 10) (x 0)) (prog2 (setf x (goodMacro 2)) (list x y)))) ;check for 10.5 (equal '(a b c) (let ((tmp '(a b c d))) (removefromlist tmp 'd))); ); close check )) ;close deftest