How to copy a list?

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!

Right. Snap's equality reporters lets you compare lists for structural equality, which is actually super useful. But where there's equality involved we don't hyperize. Another case is INDEX OF (because Snap! also wants to support you in finding the index of a sublist) But, there's a library (called "list comprehension") that lets you hyperize such blocks to whichever rank you want. And, of course, the APL library has hyperized versions of everything.

Yeah, I get that. I'm just pointing out that if a student is wrapping their head around > and < and + and most of the other nice green operator blocks are hyperized, then it confounds the expectations they are likely building up when a small handful of those blocks don't work the same way.

To be clear, I'm not saying that = should therefore be hyperized.

Yeah, that's why they need teachers. And good documentation. :~)

Download the repo, look in help folder. The filename of each .png has to match the label for that block in the source, e.g., in src/objects.js at line 290:

        bounceOffEdge: {
            only: SpriteMorph,
            type: 'command',
            category: 'motion',
            spec: 'if on edge, bounce'
        },

So the filename for the help screen for if on edge, bounce is bounceOffEdge.png (case matters, sadly).

So, pull the latest repo (not the release repo), then make a new branch, add help screens for missing things, and Github Desktop will walk you through making a pull request.

Here are blank ones to start with:
BLANK

BLANKWIDE

You can download these to edit a copy for each help screen.