How to copy a list?

It's super easy! Just do this:

As can you see, it creates a deep copy of the list:


Want a shallow copy? Do this:

You will see that only copies the top-level of the list (means that deeper ranks share the original lists)


That last picture is incomprehensible unless you show us A and B!

Maybe it should be IS ITEM 2 OF APPEND b IDENTICAL TO ITEM 2 OF B ?.

untitled script pic(2)
It report a current of list state. Really, a ID option only identity a element, and in Snap! it (probably) only is needed when you join the lists/add list to list. Briefly:
untitled script pic(3)

Oh, in BYOB was a this block:
obraz

Yes, that's from before we had linked lists, I think, so people ended up copying lists a lot, so we added a primitive just for speed.

FWIW, I was a bit confused by the original post, so I made this to prove the assertions to myself:

and then this:

which gave me this result:

Though I do find it surprising that ID OF makes a copy, deep or otherwise.

that was the reason it was even added, to make a deep copy of a list easily.

The reason why ID OF makes a deep copy is because of this thing we call hyperblocks (and others call list comprehension or APL): Most monadic and dyadic numerical functions not only accept numbers as inputs but also lists of numbers

hyper1

and arbitrarily nested lists of numbers:

in the case of a monadic function it's basically a deepmap operation on all the leafs. That's why ID ends up answering a deepcopy of whichever structure you hand it to.

Hyperblocks is actually something I'm unreasonably excited about. We've had it for 2 years now and I keep learning new stuff about it, and addressing problems in ways I never thought of before.

I don't think so. See @jens post

Okay, that makes sense. I guess of the functions in that menu ID is the only one that could be applied to the list as a whole. (I.e. the domain of the identity function is all possible values which includes lists while the rest of the functions it that menu only apply to numbers.)

But with the hyperblock thing in mind it makes sense that it turns into a deep copy. I notice that on the help for that block it doesn't say anything about it being a hyperblock? Is that because all blocks that can be are or because you don't want to confuse new programmers who might not understand what that's about or just because the help hasn't been updated? Or some other reason I'm not thinking of?

Likely

because there are a lot of images to edit to add that.

The manual documents it, though.

No, I think they're holding back because they want to use a new help system, but yeah, it might also be because of image editing.

One based on XML, which would be much, much easier to edit.

Hyperblocks is general principle for all reporters where it makes sense. Some examples:

One of my favorite examples is the Caesar cipher, which becomes all but trivial that way:

but what really excites me is what it lets us do with MediaComp:

So, recently we've even begun to support things like Mark Guzdial's famous 1-bit sound distortion example by hyperizing reporter-IF:

hyper-phone

Yeah, partly that, but also partly because I'm six deep in more urgent things that I'm already not doing. :~(

You guys could make help screens (the old way) if you want, and file a PR for me to review.

How would I do that?

It made me a bit sad though that this works as I'd expect in a hyperblock world:

but this does not:

image

I get that that's because = treats lists as regular values that it can compare. Dunno what the right answer is there. I guess you kinda need to create a specific hyperblock version of = or something. (Language design is hard!)

= block is not hiperized!