I'm wondering if it's possible to remove a nested list from a list, given a pointer to the nested list. E.g., suppose we say
(defvar y '(1 2 3))
(defvar x (list 4 5 y 6 7))
Now X is (4 5 (1 2 3) 6 7). Is there a way to use Y to modify X to (4 5 6 7)?
(setf y nil)
doesn't modify X, so it doesn't have the expected effect. The closest I've gotten is
(rplacd y nil)
which modifies X to (4 5 (1) 6 7).
EDIT: In the problem I am hoping to solve, X is a large and messy (having pointers back into itself in various places). For this reason I would am motivated to try to avoid searching X to find Y and then removing Y. This, I believe, rules out DELETE.
SECOND EDIT: X must be modified in-place. This, too, rules out DELETE, since DELETE might or might not modify X in place.