I've made a block that gives you the expanded form of a number!(Decimals work!)

It would be interesting to avoid that by manipulating the digits as text, prepending "0." then some number of zeros to digit

I get confused when you say that. (It's in a couple of threads now.) What I think you mean is "one expression" but of course there are lots of blocks in it!

But I love that you're thinking the way I do about programming style, using HOFs and composition of functions.

Oh, good idea. I would rather prefer storing some stuff in variables so some reusable values wouldn't have to be calculated again and again for each item in the list.

Here's the updated version based off of @legoman3.14's

Really cool.

You're right. I think I started saying 'one block' instead of one expression was I saw that it is all 'one' block- the untitled script pic (3) block.

I think the reason the like using HOFs and composition of functions is because I was more into math before programming, and algebra doesn't have if-then statements (At least not at a middle school level).

In 7th grade, we had to get graphing calculators to use for math, and that was when I first started programming, in TI-BASIC. It was actually a pretty cool language, and it had tons of math support built in, like matrices and hyperblock-like list behavior (2 * [1,2,3] = [2,4,6]). But since it ran on a graphing calculator, it was obviously painfully slow, and having lots of if-then statements didn't help anything. To avoid that, you tried to as many things per expression as possible. This was also before piecewise functions were added, so to graph them, you had to use the fact that False evaluated to 0 and True to 1. For example, to graph a parabola on the left side of the y-axis and a line on the right, you would write

y = (x < 0) * x^2 + (x ≥ 1) * x

As you can tell, I could go on for ages about it, but that is probably enough to bore you.

On a completely unrelated note, the built in spell-checker for Google Chrome is terrible- the options for 'painfuly' are 'panful', 'gainfully', and 'gainful'; 'painfully' is not there. :man_shrugging:

That is so APL! They do that sort of composition with multiplying by Booleans all the time.

I always tell my CS students "an ounce of math is worth a pound of CS." My favorite example is that proving there are uncomputable functions (which was the point of Turing's work on the halting problem) becomes obvious as soon as you realize that there are only countably many Turing machines.

Round it !

Except when you round in Snap!, it rounds to the nearest whole number. That means for something like 123.45 it will output 100 + 20 + 3 + 0 + 0. Or, for something like 87.9 it will output 80 + 7 + 1, which clearly is wrong.

just asking–does it work for negative numbers?
oh, and @the_meep111, Numbers in expanded form! script pic(1)

Yeah, there is something clearly wrong

you can do
[scratchblocks]
((round ((n) / (0.2))) * (0.2))
[/scratchblocks]
and it will round it to the nearest one-fifth

Yeah!

this: Numbers in expanded form! script pic(2) that is the same as your Numbers in expanded form! script pic(3) block, and the Numbers in expanded form! script pic(2) block is a primitive! just shift click the :snap: I con at the top left: Screen Shot 2021-01-22 at 2.25.02 PM (or in flat design: Screen Shot 2021-01-22 at 2.25.49 PM ), and click the last red option that says "switch to development mode". Then, the Numbers in expanded form! script pic(2) block should be there under development mode debugging primitives. Then, drag the block to the scripting area, shift click the :snap: icon again, and click the last green option that says "switch back to user mode, and you will have that still fuctional block.

Yeah, I was just experimenting around on that program...

oh! cool.

Try this new function replacing 10^

image
image

image

I like this. Can you publish this as a program. This could be really useful for a program I am working on.

how do you get the text on snap to be sharp? for me it's anti-aliased:
image
...and why is it thinner? are you using a different version of snap?

It is published! The link is on the original post.
You can save custom blocks by right-clicking them in the palette and clicking "export blocks."
image
image
From there it will download a .xml file onto your computer. Then open up the project you want the block in, and either drag the .xml file onto the editor, or click the paper icon in the top left (image ), and press "import." Either method is fine.
Here's the link again