Elisp change a value in a list

In elisp, you can use setf to change a “generalized variables”. In this way you can change a value in a list.

To my understanding, a “generalized variable” is some value “of another value”.

Usage of setf:

(setf PLACE VAL PLACE VAL ...)

PLACE is the place to be set, which should be a generalized variable.

Following functions can produce a “generalized variable” and fit into PLACE: (according to http://www.delorie.com/gnu/docs/emacs/cl_16.html)

car cdr caar .. cddddr nth rest first .. tenth aref elt nthcdr symbol-function symbol-value symbol-plist get get* getf gethash subseq

(There is another two types of eligiable values in that link.)

For example,

(setq my-list '(1 2 3 4))
(setf (car my-list) 100)
(print my-list)
;; => (100 2 3 4)