Subversion Repositories programming

Rev

Blame | Last modification | View Log | RSS feed

;Written By: Ira Snyder
;Due Date:   03-04-2005
;Homework #: HW13 (Exercise #15a)

;;; Examples of the INC* macro input, and what it is transformed into
;
; Input:  (INC* x y z)
; Output: (progn
;           (setf z (1+ z))
;           (setf y (1+ y))
;           (setf x (1+ x))
;         )
;
; Input:  (INC* a)
; Output: (progn (setf a (1+ a)))
;
; Input:  (INC*)
; Output: (progn)
;;;

;;; The INC* macro takes an unlimited number of already initialized
;;; variables and increments them by 1. Note that variables that do not
;;; already have a value CAN NOT BE INCREMENTED.
(defmacro INC* (&rest VARS)
  (do ((VARS VARS (cdr VARS))
       (RET nil))
      ((null VARS) (cons 'progn RET))
    (setf RET (cons `(setf ,(car VARS) (1+ ,(car VARS))) RET))
  )
)