Discuss Scratch

Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

So, I had an idea for new Scratch operator stuff. I need to explain it before I can give examples on how we'd use it. It could be confused with addition, but it's not addition. What if you wanted to find a certain character in a string? I'll start off using ~ as the new math symbol I want to create, and () as the separators. So let's say my string of characters is 02468 and my x value is 3. x~02468 is the equation. Since my x is 3, we're going to use VERY basic substitution. 3~02468 is now the equation. Now, count over 3 spots in the equation. What's your answer? 4 is your answer, since it is x (which is 3) spaces over in the string value, which is 02468. Understand? Good. Now, what if I wanted to do this math, but start counting over at a certain spot in the equation? You' d have to input the number you want to start on in somehow. Okay, we're keeping the string the same: 02468. What if I wanted to count over x spaces, but start counting from the 2 instead of the 0? Oh, and x is 3, still. Well, here's the equation to do that: 2(3~02468). The two in front means start at the 2. The 3~ means count over three, and the 02468 is the string value. you count it over in. So what's your answer? If you said 8, you're right!! For the final part of this, what happens if you want to start counting from a certain number, but there are two of that same number in the equation? Well, you'd have to show which number to start counting from somehow. Our new string is: 123456478901. Our new x is: 5. Well, there are two fours in the string value! What will we do?! We'll have to determine which four to start from. This is what the equation would end up looking like: 1(4(5~123456478901)). Don't worry - it's not as bad as it seems. The (4 means that we start at the four, but which four? That's what the 1(4 is for. It means that we're going to start at the first 4 of the string, starting on the left (like you read math anyway). the 5~ tells us we're going to go over 5. What's 5 over from the first 4 in the string 123456478901? If you said 8, you're a pro at this! If now, try rereading what I wrote, and seeing if you can understand! Now that I've explained it all, it's time to do one problem on your own! What's 2(4(5~123456478901))? Send me your answers! And good luck! Anyway, this was the new math symbol I thought should be added to the system. It's REALLY easy to add in onto other math (For example, 1(2~012345)*3(5/2.5) would be 18), and it can be helpful at times too, especially when coding with numerically saved string data! And again, ~ won't be the symbol used for it. But I couldn't make a new one and post it on here, could I? xD Anyway, tell me what you think about it, and if you have any questions, ask!

POSSIBLE QUESTIONS AND THEIR ANSWERS:
1) Q: What if the number you're starting on isn't in the equation? A: Well, then it's an impossible equation, and your answer should be No Solution. Just like regular math, there is always a way to have No Solution. For instance, 2x + 3 = 2x + 7 has no solution. Don't believe me, try it yourself!
2) Q: What if the equation says start on the second number, but there's only one of that number in the string? Would you just add that number onto the end of the string? A: NO WAY! You NEVER edit the string! That's like changing the value of x in an equation to make it easier on you! NEVER do that. Ever. The answer for this would be no solution as well.
3) Q: Can you use negative numbers as well? A: Of course! Do this equation: 2(6(-3~152637485960)) See, it's totally possible! The answer is 8.
4) Q: Could the string value be infinity? A: Why yes, it could. Infinity isn't just going forever - it's going forever in chronological order. Since there's only 10 characters in single digit numbers, infinity is just a repeating cycle of 012345678901234567890123456789… you get the idea. It's like a forever loop. AND, since there's no repeating value in single digit numbers (Do you see 2 fives or 3 fours in 0123456789? Nope.), you don't even NEED the first part of the equation. All you need is 4(5 ~ ∞). Get it? The first part only shows how many of that same digit you need to skip. Well, if there's only one in the entire string, then you can only have it set to 1 anyway, so why use it at all? So, for an example: 4(7 ~ ∞) would be 7 over from the 4 in the string. AND SINCE it's a repeating cycle of the same string, you wouldn't stop once you went passed 9… you'd start over at 0. So what's 4+7, as long as you start over at 0 when you get passed 9? 5, 6, 7, 8, 9, 0, 1. The answer would be 1!
Again, if you have any more questions, contact me. :D

EXAMPLES OF THIS IN SCRATCH:
Instead of parentheses, semi colons ( ; ) could be used, since they aren't used much in math (Unlike these () ). If this became a thing, and if it became a thing in SCRATCH, it'd look like this:

(;(1);(4);(5)~(123456478901)  ::operators

For an example of the use of it:
((;(1);(4);(5)~(123456478901)  ::operators) < ((2) *(3))

Yes, you can go the OPPOSITE direction sometimes. Look:
((;(2);(4);(-2)~(123456478901)  ::operators) < ((2) *(3))

Would be 5.

Another example of use is:
When Gf clicked
Forever
If ((;(2);(4);(-2)~(Var1) ::operators) < ((2) *(3))) then
Set [Var2 v] to (;(2);(4);(-2)~(Var1) ::operators


ADVANCED TOPICS (For those who understand the things above and want to further their knowledge in it):
1) SEE #4 IN “POSSIBLE QUESTIONS AND THEIR ANSWERS” BEFORE READING!! - Infinity usage in other places besides the string - Yes, this is possible. Let's start off with this: ∞(2(-3~109283657382204758202573986335293)). What this does is start a string of data, rather than a 1 digit output. To put the equation into words, I'd say, “The answer is every character that is three less than every two.” I might of worded it weirdly, but that's what it means. Find every two in the string, backtrack 3 spaces from it, then add that two your string of digits, which is your answer. Let's do it to the one above. The answer you get should be 173783. If you got that, congratulations! You actually, can't put the infinity symbol here: 1(∞(2~123456). The reason for this is because once you hit a certain point, you can't go any further unless the string goes on forever. And if you can't go any further, then the rest of the answers for the extra digits are set to “No Solution”. And if part of the answer is “No Solution”, then ALL of it is “No solution”. Like I said before, though, it WILL work if the string goes on forever. So it IS possible to have this: 1(∞(2~∞)). In words, this means, “The answer is two characters ahead of every character in the string.” And since the string goes on forever, so will the answer. If you understood what I put above in the “possible questions” section, then you'll know how infinity strings work. Anyway, if doing this problem: 1(∞(2~∞)), then the answer will be 234567890123456789012345678901…. forever. If you change the 2 in it to a -2, it'd be 89012345678901234567… forever. It starts the count two after 0, and the other one starts 2 before. And since it's infinity, it's a cycle, and since it's negative, it's reversed, so you'd go back to 8, because 0 - 2, when going back to 9 after hitting 0, is 8.
2) Combining this with other math - Yes, this is definitely very easy to combine with other math, if you ever wanted to. And like I said before, let's use ; instead of (), so we don't get it all confused. Let's start off with some simple equations. ;2;2;3~123234545676789890;;;x=2x+15. Let's break it down. What's ;2;2;3~123234545676789890;;;? 5. So substitute that in for the equation itself. 5x=2x+15. Now THIS makes a lot more sense, huh? Subtract 2x on both sides, so now you have 3x=0x+15. Anything times 0 is 0, so take out the 0x. You're left with 3x=15. Now do 15/3. The answer is 5, so x=5. Voila! You've combined it with other math! What? You want me to do another example? Okay… 3(;2;1;-1~543210987654321;;;x+;2;-3~0978653421;=57. Again, let's break it down. ;2;1;-1~543210987654321;; is what? 2. Substitute this in for the equation in the parentheses. You should have 3(2x+;2;-3~0978653421;=57. Now, let's do the other equation. What is ;2;-3~0978653421;;? 5! Again, replace it with its equation. You should NOW have 3(2x+5)=57! Finally, it's time to solve it like it's regular math. Distribute - 3*2x is 6x, and 3*5 is 15. It is now 6x + 15 =57. Subtract 15 from 57, and we get 42. You should now have 6x=42. 42/6 is 7, so x = 7. Phew! That was a lot of work!


I'd like to thank you all for reading, and I hope that the ST adds this block into the Operators section! Thank you all so much for reading! If you have any questions or comments, PLEASE comment it down below! Thank you! Also, be sure to check out my newest project, -CloudNine- for a really easy way to create cloud lists + save game data! Thank you all so much again! ~Aboot4

Last edited by Aboot4 (June 25, 2015 01:57:21)

ClearMonocle
Scratcher
42 posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

Another thing, |-5| is actually 5, so you can't use | either. It stands for absolute value, as much as I know. Sorry for constantly crashing your party.
Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

ClearMonocle wrote:

Another thing, |-5| is actually 5, so you can't use | either. It stands for absolute value, as much as I know. Sorry for constantly crashing your party.
You're right! Thanks for letting me know. We'll find SOMETHING… xD
BlueCrayfish
Scratcher
500+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

ClearMonocle wrote:

Another thing, |-5| is actually 5, so you can't use | either. It stands for absolute value, as much as I know. Sorry for constantly crashing your party.
That still doesn't mean he can't use a different symbol like \
Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

ClearMonocle wrote:

Another thing, |-5| is actually 5, so you can't use | either. It stands for absolute value, as much as I know. Sorry for constantly crashing your party.
You're right! I'm changing it right now.
Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

ClearMonocle wrote:

Another thing, |-5| is actually 5, so you can't use | either. It stands for absolute value, as much as I know. Sorry for constantly crashing your party.
Fixed!
seanbobe
Scratcher
500+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

can i change it a bit?

(a);(b);(c) ~ (string) :: reporter
go (c) spaces foward starting from the (a)th (b) in (string) :: reporter

it is green.

Last edited by seanbobe (June 25, 2015 02:03:41)

DaSpudLord
Scratcher
1000+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

No support. It appears extemely complicated, so new scratchers might not know what it does.
gdpr533f604550b2f20900645890
Scratcher
1000+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

No support. The existing operators are based on actual aspects of math. Scratch shouldn't have an operator based on something a Scratcher made up because it isn't a widely accepted operator. Besides, your idea can be worked around with this block:
(letter () of [])
define ~ (version of starting point)(spaces) (starting point) (number)
set [counter v] to (0)
set [counter2 v] to (0)
repeat until <(counter2) = (version of starting point)//look for where to start counting digits
change [counter v] by (1)
repeat until <(letter (counter) of (number)) = (starting point)>//look for a potential starting point ERROR HERE
change [counter v] by (1)
end
change [counter2 v] by (1)//change the amount of starting points checked
end
if <(spaces) = ([abs v] of (spaces))> then//Are you counting backwards or forwards?
repeat (spaces)//count forwards
change [counter v] by (1)
end
return (letter (counter) of (number))//return answer
else
repeat ([abs v] of (spaces))
change [counter v] by (-1)//count backwards
end
return (letter (counter) of (number))//return answer
end
EDIT: FIXED

Last edited by gdpr533f604550b2f20900645890 (June 25, 2015 03:16:48)

Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

seanbobe wrote:

can i change it a bit?

(a);(b);(c) ~ (string) :: reporter
go (c) spaces foward starting from the (a)th (b) in (string) :: reporter

it is green.
1) You actually worded it wrong from how the actual formula does it. The second number is where you start counting from, the first one only EXISTS if there is multiple of the second one, and the third one is how many over you count in the string, which is after the ~.
2)Makes more sense, but it's way too long. Also, did you know that after you make a block like you did there, if you do :: operators then it will become green? If you do :: looks, it becomes purple, and if you do :: control it becomes yellow. It works for every section of block. And if you want it to be a hat, (Like “When Green Flag Clicked” has the rounded top) then do :: hat operators. See?
(Go over (a) spaces from the (2nd v) (c) in (string) ::operators
^ This is a better way to word it, if were going to change it. Only it's waaaayy too long.

Last edited by Aboot4 (June 25, 2015 02:22:53)

Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

There IS actually a way to make
(Go over (a) spaces from the (2nd v) (c) in (string) ::operators
happen in Scratch. In fact, I think that'll be my next project, if I can ever figure out how to get it to work!
gdpr533f604550b2f20900645890
Scratcher
1000+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

Aboot4 wrote:

There IS actually a way to make
(Go over (a) spaces from the (2nd v) (c) in (string) ::operators
happen in Scratch. In fact, I think that'll be my next project, if I can ever figure out how to get it to work!
Did you see my script? I already created a function that does what you want.
rollercoasterfan
Scratcher
1000+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

A couple of things.

Personally, I love the idea. However, it seems too advanced for new scratchers. You could just say that the mod, log and cos are too advanced for scratchers, but those are real math functions, and this isn't. I don't see the ST adding an operator block that isn't a real math function.

Second, there aren't many uses for this. The ST has said that every new block is thought hard on, and well discussed. Every new block that comes in needs to be useful, because each block makes scratch that much harder.

I'm sorry, but this wouldn't work well with Scratch. No support.
Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

Chibi-Matoran wrote:

Aboot4 wrote:

There IS actually a way to make
(Go over (a) spaces from the (2nd v) (c) in (string) ::operators
happen in Scratch. In fact, I think that'll be my next project, if I can ever figure out how to get it to work!
Did you see my script? I already created a function that does what you want.
Dang bro. xD
Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

Chibi-Matoran wrote:

No support. The existing operators are based on actual aspects of math. Scratch shouldn't have an operator based on something a Scratcher made up because it isn't a widely accepted operator. Besides, your idea can be worked around with this block:
(letter () of [])
define ~ (version of starting point)(spaces) (starting point) (number)
set [counter2 v] to (0)
repeat until <(counter2) = (version of starting point)//look for where to start counting digits
set [counter v] to (0)
repeat until <(letter (counter) of (number)) = (starting point)>//look for a potential starting point
change [counter v] by (1)
end
change [counter2 v] by (1)//change the amount of starting points checked
end
if <(spaces) = ([abs v] of (spaces))> then//Are you counting backwards or forwards?
repeat (spaces)//count forwards
change [counter v] by (1)
end
return (letter (counter) of (number))//return answer
else
repeat ([abs v] of (spaces))
change [counter v] by (-1)//count backwards
end
return (letter (counter) of (number))//return answer
end
May I use this?
TheMonsterOfTheDeep
Scratcher
1000+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

This isn't really “major maths” - it's really just counting skills.

However, I don't really see this block having any use, so I don't support. Sorry.

Here's a workaround, for convenience. I didn't understand what you were getting at with “infinity” and stuff, so I'm not going to bother with that. As it is, this block wouldn't make sense in the context of infinity, because infinity has no value other than “infinity”, and there are also different types of infinity.
define ; (index) ; (start) ; (offset) ~ (string)
set [start index v] to [0]
set [count v] to [0]
repeat until <(count) = (index)>
repeat until <(letter (start index) of (string)) = (start)>
change [start index v] by [1]
if <(start index) > (length of (string))> then
set [return v] to [err]
stop [this script v]
end
end
change [count v] by [1]
if <not <(count) = (index)>> then
change [start index v] by [1]
end
end
if <<(offset) < [0]> and <(start index) = [0]>> then
set [start index v] to (length of (string))
end
set [return v] to (letter ((start index) + (offset)) of (string))
if <(length of (return)) = [0]> then
set [return v] to [err]
end
gdpr533f604550b2f20900645890
Scratcher
1000+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

Aboot4 wrote:

Chibi-Matoran wrote:

No support. The existing operators are based on actual aspects of math. Scratch shouldn't have an operator based on something a Scratcher made up because it isn't a widely accepted operator. Besides, your idea can be worked around with this block:
(letter () of [])
define ~ (version of starting point)(spaces) (starting point) (number)
set [counter2 v] to (0)
repeat until <(counter2) = (version of starting point)//look for where to start counting digits
set [counter v] to (0)
repeat until <(letter (counter) of (number)) = (starting point)>//look for a potential starting point
change [counter v] by (1)
end
change [counter2 v] by (1)//change the amount of starting points checked
end
if <(spaces) = ([abs v] of (spaces))> then//Are you counting backwards or forwards?
repeat (spaces)//count forwards
change [counter v] by (1)
end
return (letter (counter) of (number))//return answer
else
repeat ([abs v] of (spaces))
change [counter v] by (-1)//count backwards
end
return (letter (counter) of (number))//return answer
end
May I use this?
Okay, but I just found a glitch, so you might want to see my newer version. And I didn't test the block, so I don't know if it works. Also, Scratch doesn't have a “return ()” block; I made it up since functions in other languages can return values, so you will have to create a variable that represents the return value.

Last edited by gdpr533f604550b2f20900645890 (June 25, 2015 02:31:28)

Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

Chibi-Matoran wrote:

Aboot4 wrote:

Chibi-Matoran wrote:

No support. The existing operators are based on actual aspects of math. Scratch shouldn't have an operator based on something a Scratcher made up because it isn't a widely accepted operator. Besides, your idea can be worked around with this block:
(letter () of [])
define ~ (version of starting point)(spaces) (starting point) (number)
set [counter2 v] to (0)
repeat until <(counter2) = (version of starting point)//look for where to start counting digits
set [counter v] to (0)
repeat until <(letter (counter) of (number)) = (starting point)>//look for a potential starting point
change [counter v] by (1)
end
change [counter2 v] by (1)//change the amount of starting points checked
end
if <(spaces) = ([abs v] of (spaces))> then//Are you counting backwards or forwards?
repeat (spaces)//count forwards
change [counter v] by (1)
end
return (letter (counter) of (number))//return answer
else
repeat ([abs v] of (spaces))
change [counter v] by (-1)//count backwards
end
return (letter (counter) of (number))//return answer
end
May I use this?
Okay, but I just found a glitch, so you might want to see my newer version. And I didn't test the block, so I don't know if it works. Also, Scratch doesn't have a “return ()” block; I made it up since functions in other languages can return values, so you will have to create a variable that represents the return value.
Which one is the new version?
TheMonsterOfTheDeep
Scratcher
1000+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

Also, @Chibi-Mataron, your workaround doesn't work - it won't return the right value if the starting point is not the first number.

Darn, ninja'd again.

Last edited by TheMonsterOfTheDeep (June 25, 2015 02:37:30)

Aboot4
Scratcher
100+ posts

New Operators Block? WARNING: MAJOR MATHS!! Smart People Recommended xP

TheMonsterOfTheDeep wrote:

This isn't really “major maths” - it's really just counting skills.

However, I don't really see this block having any use, so I don't support. Sorry.

Here's a workaround, for convenience. I didn't understand what you were getting at with “infinity” and stuff, so I'm not going to bother with that. As it is, this block wouldn't make sense in the context of infinity, because infinity has no value other than “infinity”, and there are also different types of infinity.
define ; (index) ; (start) ; (offset) ~ (string)
set [start index v] to [0]
set [count v] to [0]
repeat until <(count) = (index)>
repeat until <(letter (start index) of (string)) = (start)>
change [start index v] by [1]
if <(start index) > (length of (string))> then
set [return v] to [err]
stop [this script v]
end
end
change [count v] by [1]
if <not <(count) = (index)>> then
change [start index v] by [1]
end
end
if <<(offset) < [0]> and <(start index) = [0]>> then
set [start index v] to (length of (string))
end
set [return v] to (letter ((start index) + (offset)) of (string))
if <(length of (return)) = [0]> then
set [return v] to [err]
end
Why did you put “err”? And what would I put there? xP

Last edited by Aboot4 (June 25, 2015 02:39:34)

Powered by DjangoBB