Reverse
creates and returns a new list. Rotatef
(just as setf
, incf
and the like) modify a place. You will have to copy-list
or copy-tree
your element
to create a new list that you then modify.
Some other remarks:
instead of a getter and setter method, use an accessor method. That's usually preferred.
lists are created with functions like LIST or COPY-LIST. A list written as '(1 b 2) is in source code a literal constant and should not be changed. It is undefined in the CL standard what happens if you try to change a literal list. This can have unwanted effects. If you have a literal list and you want to modify it, you should first copy it with COPY-LIST (or COPY-TREE) and modify that copy.
you also need to learn the difference between non-destructive operations like REVERSE and possibly destructive operations like NREVERSE. If you want the original list to be unchanged, use non-destructive operations. The nature of the list or sequence operations is described in the Common Lisp Hyperspec for each operation.