I'm trying to copy a list A in a way that changing the lists inside A don't
affect B.
I've tried using 'copy, like this:

: (setq A '((1 2 3) (4 5 6)))
-> ((1 2 3) (4 5 6))
: (setq B (copy A))
-> ((1 2 3) (4 5 6))

And it works at the top level:
#changing B doesn't change A
: (set B 1)
-> 1
: B
-> (1 (4 5 6))
: A
-> ((1 2 3) (4 5 6))

But, as the documentation says, it works only at the top level of the list:
#changing the CAR of B changes the CAR of A
: (setq B (copy A))
-> ((1 2 3) (4 5 6))
: (set (car B) 'a)
-> a
: B
-> ((a 2 3) (4 5 6))
: A
-> ((a 2 3) (4 5 6))

Is there a function that would copy A so that no changes in any of the
nested lists in A would change B, and vice versa?
Also, as a more general question, is there a name for when two variables
are entangled like this? Where changing one changes the other?

Reply via email to