Re:Python Multiple Assignment Is a Puzzle
by malisper on Sunday July 27, 2014 @05:04PM
(#8093963)
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).
There is also setf and psetf which in the examples I'm giving evaluate from lowest suffix to highest (same as todd8).
[0] http://clhs.lisp.se/Body/m_rotate.htm