I probably wouldn't write a macro for this problem, I would isolate the problem of 'stealing' an item from a list:
(defmacro awhen (test &rest code)
`(let ((it ,test))
(when it ,@code)))
(defun steal (n list)
(awhen (nthcdr (1- n) list)
(prog1 (cadr it) (rplacd it (cddr it)))))
And it is used like this:
(defvar *test-input* '(a b c d e f g))
(steal 1 *test-input*) ;; Returns 'b, *test-output* is now (a c d e f g)
There is one problem --- what happens if you steal item 0 from a list? It won't work, and it cannot be made to work because steal is a utility function, and it would be unwise to hardcode it so it would setf *test-input* to (cdr *test-input*) for the zero case. However, we can write a function using steal that has this knowledge.
(defvar *input* '(a b c d e))
(defvar *output* nil)
(defun steal/pop (n)
(if (and *test-input* (zerop n))
(setf *output* (cons (car *input*) *output*)
*input* (cdr *input*))
(and (< n (length *input*)) (push (steal n *input*) *output*))))
This method does exactly what you describe. It steals the Nth element from *input*, and pushes it onto *output*, I also made it do bounds checking so it won't do anything if N is larger than *input*. The routine is hardcoded to reference those external variables, which is ideal because its simple.
If you have a number of lists that you need to modify, and you don't want to have a customized steal routine for each one, you can use a sentinal value like so:
(defvar *new-input* '(sentinal a b c d e))
By putting a sentinal value in as item 0, we have no reason to ever require a (steal 0 *new-input*). This works fine so long as we remember to perform all other operations (like length, find, position, etc) upon (cdr *new-input*) and not the full *new-input*.
Need an online wiki database? My Lisp startup
http://www.formlis.com combines a wiki with forms and reports.