Problems when copying two-dimensional lists

Let Original be a list. Then SET Copy TO Original does not provide a real copy. Changes by ADD or REPLACEe affect the copy.

MAP provided an elegant solution:

MAP ... OVER Original returns a true copy of Original, i.e. the copy remains unchanged even if Original is changed by REPLACE or ADD.

Until now, this also worked for linked lists with MAP … OVER (MAP … OVER Original)

In the latest version, the resulting two-dimensional copy is protected against the addition of new partial lists, but not against the modification of individual elements by REPLACE and not against the appending of elements to individual partial lists with ADD.

If one goes through the individual elements with a FOR loop or a EACH ITEM OF, one gets the error message

Inside a custom block
TypeError
Cannot read properties of undefined (reading 'length')
The question came up at
Map ... over item i of myList

Is there es new elegant solution to get a real copy of a linked list?

Let Original be a list. Then SET Copy TO Original does not provide a real copy. Changes by ADD or REPLACEe affect the copy.

MAP provided an elegant solution:

MAP ... OVER Original returns a true copy of Original, i.e. the copy remains unchanged even if Original is changed by REPLACE or ADD.

Until now, this also worked for linked lists with MAP … OVER (MAP … OVER Original)

In the latest version, the resulting two-dimensional copy is protected against the addition of new partial lists, but not against the modification of individual elements by REPLACE and not against the appending of elements to individual partial lists with ADD.

If one goes through the individual elements with a FOR loop or a EACH ITEM OF, one gets the error message

Inside a custom block
TypeError
Cannot read properties of undefined (reading 'length')
The question came up at
Map ... over item i of myList

Is there es new elegant solution to get a real copy of a linked list?

windows script pic (1)
its hyperblock

Interesting! I have no idea what it's doing or why.

But this works:

ID is the bottommost entry in the SQRT menu.

Hi Fritz!
I'm trying to understand the issue. Can you perhaps post or send me an example script? Where did you get the COPY block from? I think I understand that the issue happens with 2-dimensional linked lists which you'd like to shallow-copy, right? In this case what does using REPLACE on a "sublist" mean? Replacing the whole sublist for another, or replacing a leaf-item of the sublist for another value?
Thanks!

A quick test in the current release does exactly what I would expect:

Can you show a screenshot of the bug and of the error message?
Thanks!

It's not a bug, I think they are talking about linked lists.

I believe that doing a REPLACE ITEM converts the list to array form. That shouldn't change the result, though.

Problem solved. Actually, I think I was looking for something like the deep-copy-Function, which now has been implemented with id.
Thank you for your efforts.

thank you, Fritz! I'm really glad this now works for you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.