(defmacro first-item (lst) (list 'car lst) ) (defmacro rest-of-items (lst) (list 'cdr lst) )
(defmacro first-item2 (lst) `(car ,lst) ) (defmacro rest-of-items2 (lst) `(cdr ,lst) )
(defmacro for (var init final &rest body) (let ((start-var (gensym)) ; Gensym's prevent variable capture (count (gensym)) (fin (gensym)) ) `(do ((,start-var ,var) ; Bound only on first iteration (b (boundp ,var)) ; -- Prevents multiple evaluation (,fin ,final) (,count ,init (+ ,count 1)) ) ((= ,fin ,count) (if b (setf ,var ,start-var) (makunbound ,var) ) ) (setf ,var ,count) ,@body ) ) )