In this script I would like the underscored line variable to be replaced with the answer if the answer is in the secret word. While this works, if there is multiple letters that are the same in the word the index only reports the first item number where it appears. Is there any way to have it report multiple item numbers?
Link to project: Snap! Build Your Own Blocks
its a little complex but this should work
lmk if you need something else
Sorry I am just now seeing this thank you for trying to help me but I cant export the script pic into my project. Its js empty whenever I look inside of it.
it shouldnt be too hard to recreate the block in the picture, i cant really do anything about the script pic importer sadly
Click on the image, a new window will appear: save this image and import it
or you can drag and drop the image into snap
your script can be simplified
so i tried to implement this script but ion know where to find the "input names: block at. could u pls help me? also does this work with my program? i want it to replace those values of where the letter is in the underscore part to the correctly guessed letter. so instead of this:
ik u can do this im js saying the script isnt exporting correctly for some reason
click the black arrow on the grey ring
That happens when they create the block, but forget to click apply before getting the script pic.
This is how I prefer to do it
At first I wondered why you’re using
… but then it dawned on me that the seemingly simpler alternative
… will produce a faulty result if the original list is empty and item = “”:
IMO the most elegant alternative, using the APL primitives library, is:
… ought to be the Snap! standard, while
… is a deviation.
Yeah yeah. This is (indirectly) my fault. Back when all these utilities were library procedures written in Snap!, I wrote the official implementation of FOR:
My entire reason for allowing stepping downward was to have a semi-reasonable reason to ringify a function, for teaching purposes.
Anyway, eventually we turned all those utilities into primitives (written in JS) for speed, when Jens got interested in media computation and therefore very concerned to make everything as fast as possible.
But when we decided to add NUMBERS FROM, Jens deliberately took FOR as a model and chose to make the stepping consistent. Thus my initial design choice spread out.
So I'm pushing for either
or two separate blocks, and similarly for NUMBERS FROM.
You have to press the right arrow on the ring twice
I knew about that but I wanted to make it as simple to understand as possible as they are a beginner
Maybe that makes more sense to you and I’m the one who’s coming up with more complex things, idk
We all have different programming techniques ig
I like to make custom blocks as compact as possible.
So do I, but I only do it to the point it’s still easy enough to understand how it works
Is there anyway that I can use these multiple indexes to replace multiple items in a list? is that even possible? thank you for your help btw
Yep, the “replace” block accepts list inputs for the item numbers so it should work perfectly fine