5.6.2 Altering the CDR of a List

This function stores object as the new CDR of cons,
replacing its previous CDR. In other words, it changes the
CDR slot of cons to refer to object. It returns the
value object.

Here is an example of replacing the CDR of a list with a
different list. All but the first element of the list are removed in
favor of a different sequence of elements. The first element is
unchanged, because it resides in the CAR of the list, and is not
reached via the CDR.

(setq x '(1 2 3))
⇒ (1 2 3)

(setcdr x '(4))
⇒ (4)

x
⇒ (1 4)

You can delete elements from the middle of a list by altering the
CDRs of the cons cells in the list. For example, here we delete
the second element, b, from the list (a b c), by changing
the CDR of the first cons cell: