I like how you give both a rationale (of sorts) against, then a demonstration nevertheless of a deep copy. Very friendly! :)
> 5 dec. 2016 kl. 08:43 skrev Alexander Burger <a...@software-lab.de>: > >> On Mon, Dec 05, 2016 at 01:44:53AM -0500, Bruno Franco wrote: >> 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? > > You mean a "deep copy". > > Contrary to what one might expect, it is very rarely needed. At least I never > needed it in my 35 years of Lisp. I almost never used even the single-level > 'copy' function. > > Instead, you would rather re-consider your data structures, and operate on > them > in a non-destructive way. > > > Having said this, you can do e.g. a 2-level copy with > > (mapcar copy List) > > For an arbitrary depth you must use recursion > > (recur (List) > (if (atom List) > List > (cons (recurse (car List)) (recurse (cdr List))) ) ) > > >> Also, as a more general question, is there a name for when two variables >> are entangled like this? Where changing one changes the other? > > The term is "destructive" operations. In the PicoLisp reference, all > destructive > functions should be marked as that. > > ♪♫ Alex > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe