Continuing through obscure Lisp commands, we arrive at the shiftf macro. This is very similar to the rotatef macro that we described earlier. The difference is that the first place, rather than rotating to the last place as in rotatef, is removed and a new programmer-supplied value is inserted into the last place. The dropped value is returned. Here are some examples:
CL-USER> (let ((one 1) (two 2) (three 3)) (rotatef one two three) (format t "After rotatef, one= ~D two= ~D three= ~D~%" one two three)) After rotatef, one= 2 two= 3 three= 1 NIL CL-USER> (let ((one 1) (two 2) (three 3)) (shiftf one two three 10) (format t "After shiftf, one= ~D two= ~D three= ~D~%" one two three)) After shiftf, one= 2 two= 3 three= 10 NIL CL-USER> (let ((mylist (list 1 2 3 4 5))) (rotatef (first mylist) (second mylist) (third mylist)) (format t "After rotatef, mylist= ~A~%" mylist)) After rotatef, mylist= (2 3 1 4 5) NIL CL-USER> (let ((mylist (list 1 2 3 4 5))) (shiftf (first mylist) (second mylist) (third mylist) 10) (format t "After shiftf, mylist= ~A~%" mylist)) After shiftf, mylist= (2 3 10 4 5) NIL