Subversion Repositories programming

Rev

Rev 74 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
74 irasnyd 1
;Written By: Ira Snyder
2
;Due Date:   03-04-2005
3
;Homework #: HW13 (Exercise #15a)
4
 
5
;;; Examples of the INC* macro input, and what it is transformed into
6
;
7
; Input:  (INC* x y z)
8
; Output: (progn
9
;           (setf z (1+ z))
10
;           (setf y (1+ y))
11
;           (setf x (1+ x))
12
;         )
13
;
14
; Input:  (INC* a)
15
; Output: (progn (setf a (1+ a)))
16
;
17
; Input:  (INC*)
18
; Output: (progn)
19
;;;
20
 
21
;;; The INC* macro takes an unlimited number of already initialized
22
;;; variables and increments them by 1. Note that variables that do not
23
;;; already have a value CAN NOT BE INCREMENTED.
24
(defmacro INC* (&rest VARS)
25
  (do ((VARS VARS (cdr VARS))
26
       (RET nil))
27
      ((null VARS) (cons 'progn RET))
28
    (setf RET (cons `(setf ,(car VARS) (1+ ,(car VARS))) RET))
29
  )
30
)