Subversion Repositories programming

Rev

Rev 100 | 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)
108 ira 4
;License: Public Domain
74 irasnyd 5
 
6
;;; Examples of the INC* macro input, and what it is transformed into
7
;
8
; Input:  (INC* x y z)
9
; Output: (progn
10
;           (setf z (1+ z))
11
;           (setf y (1+ y))
12
;           (setf x (1+ x))
13
;         )
14
;
15
; Input:  (INC* a)
16
; Output: (progn (setf a (1+ a)))
17
;
18
; Input:  (INC*)
19
; Output: (progn)
20
;;;
21
 
22
;;; The INC* macro takes an unlimited number of already initialized
23
;;; variables and increments them by 1. Note that variables that do not
24
;;; already have a value CAN NOT BE INCREMENTED.
25
(defmacro INC* (&rest VARS)
26
  (do ((VARS VARS (cdr VARS))
27
       (RET nil))
28
      ((null VARS) (cons 'progn RET))
29
    (setf RET (cons `(setf ,(car VARS) (1+ ,(car VARS))) RET))
30
  )
31
)