This is just a showcase for the most used block that you’ve coded up in Snap! that you actually use frequently in your own projects
Mine is this slice reporter
It’s coloured red and green to show it works on lists as well as text
It uses the concept of last item being position -1
I use it quite a lot
or
I made this block a while back, it is useful for making music within Snap!.
This block takes lists as an input. The list should be 2 or 3 items long. The first item is the note, the second item is how many beats you want the note to be played for, and the 3rd optional item is how many beats you want of rest.
We start with a list of letters A-J with many duplicates. We now sort the list to group all the A’s together, all the B’s together, etcetera. Next, we add a little one to the start of each to say “there is one copy of this letter”. Finally, we combine items if the letter is the same by adding up their numbers!
There are many use cases I have found, especially doing Advent of Code (which I still need to finish).
PS: I think a list utils library has an assoc block that does the above example, but there are other use cases, like I said. That was just an example.
PPS: Because it uses combine internally, you can make a compiled version too:
Sorry, I just thought it might be a nice addition to their block; a way to engage with their post… I wasn’t trying to make an additional submission (or whatever you want to call it). I had read the rule :).
Despite Jens’s new library using first class colors, I’m still really proud of this block. It knows about HSL, HSV, RGB, X11 color names, crayons, RGB in hex, you name it. The whole colors and crayons library is full of such gems as
simulated paint mixing, which is hugely complicated, because chemistry.
The block’s almost impossible to see; but the top C-Slot runs in the background, and the bottom slot is for when you click the sprite/button. There’s some added animations to make it move and grow like a button