4 ms·
From the standard[0], "In the form (rotatef place1 place2 ... placen), the values in place1 through placen are read and written. Values 2 through n and value 1
by malisper 12y ago
From the standard[0], "In the form (rotatef place1 place2 ... placen), the values in place1 through placen are read and written. Values 2 through n and value 1 are then stored into place1 through placen. It is as if all the places form an end-around shift register that is rotated one place to the left, with the value of place1 being shifted around the end to placen." The key word being place Once (elt A 0) and (elt A (1- (elt A 0))) are evaluated rotatef keeps track of the places and the values at those locations. It then assigns the values to the places; it does not reevaluate the expressions.
There is also setf and psetf which in the examples I'm giving evaluate from lowest suffix to highest (same as todd8).
(setf expr2 expr1
expr4 expr3)
(psetf expr3 expr1
expr4 expr2)
[0] http://clhs.lisp.se/Body/m_rotate.htm http://clhs.lisp.se/Body/m_rotate.htm