Discuss Scratch

Gameknight666
Scratcher
3 posts

Add Parenthesis to the operators section

Hi Scratchers and Scratch Team,
I'm @Gameknight666, and I'd like Scratch to have parenthesis in the operators section of code. I want this because I want Scratch to be able to solve equations that have to do with the order of operations.
I'd really like to have it!
Regards,
Gameknight
ChocolatePi
Scratcher
1000+ posts

Add Parenthesis to the operators section

You can already do this with what we have!

The equivalent of
 ( 1 + 2 ) * 3 

in blocks is

1+2*3

Think of each block as having parenthesis around it
Gameknight666
Scratcher
3 posts

Add Parenthesis to the operators section

I see now. Thanks!
rpbourret
Scratcher
1 post

Add Parenthesis to the operators section

It would be really helpful if parentheses were actually drawn on the ends of the lozenges in the Operators section. Once you nest operators deeply enough, it's really hard to see how they fit together.

– Ron

JJ_Cuber
Scratcher
2 posts

Add Parenthesis to the operators section

I also agree on that, because of the equation √(XX - XY)² + (YX - YY)² (AKA the equation for solving distance) (because I was working on a game and it needed the calculation of distance,) so that would be very helpful and useful!
Solmux
Scratcher
100+ posts

Add Parenthesis to the operators section

rpbourret wrote:

It would be really helpful if parentheses were actually drawn on the ends of the lozenges in the Operators section. Once you nest operators deeply enough, it's really hard to see how they fit together.

– Ron


Please post your suggestions in a separate topic.
i think

Also,
10+5+2
Pixelguy1087
Scratcher
4 posts

Add Parenthesis to the operators section

ChocolatePi wrote:

You can already do this with what we have!

The equivalent of
 ( 1 + 2 ) * 3 

in blocks is

1+2*3

Think of each block as having parenthesis around it
Ikr, its so cool!
whenclickedsayYeah!defineParentasessetto(((1) + (2)) * (3))
badatprogrammingibe
Scratcher
500+ posts

Add Parenthesis to the operators section

Pixelguy1087 wrote:

ChocolatePi wrote:

You can already do this with what we have!

The equivalent of
 ( 1 + 2 ) * 3 

in blocks is

1+2*3

Think of each block as having parenthesis around it
Ikr, its so cool!
whenclickedsayYeah!defineParentasessetto(((1) + (2)) * (3))
I agree.
XayCraft360
Scratcher
100+ posts

Add Parenthesis to the operators section

No support, you could just put different reporters together, because the OoO doesn't actually exist in scratch, and a reporter in another reporter gives the value of the first reporter with the second reporter
Sigton
Scratcher
1000+ posts

Add Parenthesis to the operators section

XayCraft360 wrote:

No support, you could just put different reporters together, because the OoO doesn't actually exist in scratch, and a reporter in another reporter gives the value of the first reporter with the second reporter
Well I'd say the that Order of Operations is much more explicit in Scratch than in other uses. Say if I asked you to calculate 1 + 2 * 3, then you implicitly apply the order of operations and do 2*3 first. However, in Scratch EVERYTHING has brackets around it, effectively, so it is nice and easy to see and manipulate the order of operations.

Sigton
space_elephant
Scratcher
500+ posts

Add Parenthesis to the operators section

toch uses this:
1 + 2 * 3 // returns 7
in blocks is
1+2*3returns 7
but
( 1 + 2 ) * 3 // returns 9
is required for
1+2*3returns 9
as you can see, the scratch blocks have brackets in all cases, not just where they are required.

Last edited by space_elephant (Nov. 19, 2018 16:37:03)

space_elephant
Scratcher
500+ posts

Add Parenthesis to the operators section

scratch wrote:

whenclickedclearpendownsettimesto0deleteallofx posrepeatuntilmousedown?andtouchingmouse-pointermove2stepsturn2degreessayjoinI am at ypositionchangetimesby1ifpickrandom0to1=1thenaddxpositiontox pospenupplaysoundmeowuntildoneforevergotoxwithout screen refreshwait1secsto enable the user to see each one clearlydefinegotoxgotox:itemrandomofx posy:itemrandomofx pospointindirectionpickrandom-179to180repeatuntiltouchingedgechangeyby-1

tosh wrote:

when green flag clicked
clear
pen down

set times to 0
delete all of x pos
repeat until mouse down? and touching mouse-pointer
move 2 steps
turn right
2 degrees
say join “I am at ” y position
change times by 1
if pick random 0 to 1 = 1 then
add x position to x pos
end
end

pen up
play sound “meow” until done
forever
go to x // without screen refresh
wait 1 secs // to enable the user to see each one clearly
end

define-atomic go to x
go to x: item random of x pos y: item random of x pos
point in direction pick random -179 to 180
repeat until touching edge
change y by -1
end
space_elephant
Scratcher
500+ posts

Add Parenthesis to the operators section

did you want to show the brackets on the blocks?
(+)(-)(*)(/)(sqrtof9)
Catlover39765
Scratcher
2 posts

Add Parenthesis to the operators section

this is brackets

Powered by DjangoBB