An ongoing project: Purely Functional Snap!

Nah I’m transfem

I see.


How should sounds work?

Here’s a cool fact we can use!
Sounds are actually a data type whenever they are represented in lists!
IMG_1586

Let me make a demo of an idea I have

Okay!


Also, should we instead of just pass through a sprite in motion and looks, should we clone the sprite first?

No, the user chooses themselves

Purely Functional Snap! script pic 24
Here’s sound implementation so far

I shared my version Snap! Build Your Own Blocks Use that for the latest update

I have no idea if this works as I’m on iOS where sound is broken

Your project is not shared, bro. :slightly_frowning_face:

try now

Your project is now shared, that's good! :smiley:

I just tried, and I can't get to it.

I also cannot access it
image

I see. You forgot the ! at the end of the URL.

no i removed the ! on my end
the ! cant be in a url

W/O the !:


W/ the !:

(It worked)

I believe reporters don't yield without needing to be warped.

Two problems here. First, why are you declaring the first input to LET as being of type Reporter (variadic)? You don't want promises to do what's in the rings later, especially since your code never calls them; that is, LET doesn't have anything like
untitled script pic (5)
Secondly, Snap! has this do-what-I-mean feature that when you put a variable into a ring, it's automatically unringified, on the theory that the value of the variable is a procedure, as in this kind of code:


The two circled instances of the variable FUNC occupy Reporter (ringed) input slots, but as soon as you drag in the variable, the ring disappears. (Drag the variable back out, and the ring reappears.)

Even for advanced users, this behavior is The Right Thing 95% of the time, and for beginners it's The Right Thing 100% of the time. But it does mean that part of being an advanced user is keeping an eye out for the other 5%.

In your case, the variable is in scope if you use it in a larger expression:


and it'll be in scope by itself too if you remember to ringify it, to undo Snap! doing you the favor of unringifying it:
untitled script pic (4)

Nope. Not functional. You're not allowed to modify the input list. You could make a copy of it, in a script variable, and then use DELETE on that, although even that would be a little uncool. The really functional way would be to build up the copy, item by item (using a recursive call to your function), skipping over the one you don't want.

I don't understand this. ACTION is called once with no inputs and once with one input. What is it expecting? Is it a one-input function, but if you call it with no inputs, nothing gets substituted into the empty slots, and so the initial value is the empty string?

Also, @bluebaritone21, looking at this use of your arithmetic pulldown function makes it clear to me that you should be using − (MINUS SIGN, U+2212) in the menu instead of the nearly-invisible hyphen.

Sounds are a data type, period. There's nothing special about putting them in lists. (This is always the case. Anything that can be a list item can also be used as a value in any other context.)

How's mine? I used keep to make delete, and map for everything else.

Huh. Didn't know that existed.

That's fine. Have you tried timing

instead of APPEND to implement ADD? (Btw, I'd call it ADDED not APPENDED because the latter makes me think the input is a list to be appended rather than a single item.)

About this:
untitled script pic (3)
If you'd like to try to center the expressions above and below the Sigma, let me commend to your attention the character INVISIBLE TIMES (U+2062), the only nonprinting character I've yet found that Snap! doesn't just ignore as title text. If you put one of those before and after a bunch of spaces, you can make a piece of title text that'll shift the rest of its line rightward:
untitled script pic (4)

And also, that Sigma is kinda scrawny surrounded by all that other stuff; I'd use $∑-1.5 instead:
untitled script pic (5)

(Sorry, I've just been reading a book about digital typography.)

Wait, there's a reverse of list block?!

:~) It's one of the many (many) options in the LENGTH block.

Or, for faster execution with large lists, use item of:

This definition takes care of dictionaries, too:

It;s purely functional, though not as elegant, perhaps, as an item-by-tem approach.