So Snap!'s goal is to add a small amount of primitives to be able to create a big amount of custom blocks. The primitives MAP, FILTER, FIND, REDUCE, FOR EACH are there for speed. But often-times when I’m building list blocks I feel like an EVERY/SOME block is missing. I have to manually make a slow, inefficient script to check. So I suggest to either
add a new primitive for speed
add a new extension for the same purpose and add it to the list utilities library
Though the benefit my custom block has over the second way, is that it doesn’t run anything extra if an item is found. The map method always maps over the entire list no matter what.
It’s a bit of a pick and choose situation here. If you anticipate having the value in the list more often than not, then it might be faster with my custom block. But if you anticipate not having it a lot, then it might be faster with the map method.
My custom block is also designed so that you can have empty values in the list (and check for them), but if you don’t, it’s much much faster to just use FIRST OF directly (no creating a new list of indices).
Basically I’m trying to say, most of the time, we don’t need a primitive for speed, in fact, this block would actually be just as fast as FIRST OF. It only becomes necessary if lots of people are using it, and you can’t get the same effect any other way.
Side note
This is not hyperblocks, this is just a variadic input. Hyperblocks is inputting a list, doing the operation on every item, and returning a new list.