I'm making some sort of thing that evaluates brackets in the correct order by using a stack.
I'll upload it tomorrow, then we can start putting the math functions on it.
At the moment it just extracts nested brackets into a stack structure.
Offline
TheSuccessor wrote:
I'm making some sort of thing that evaluates brackets in the correct order by using a stack.
I'll upload it tomorrow, then we can start putting the math functions on it.
At the moment it just extracts nested brackets into a stack structure.
Upload it.
I still need to find out how to do a stack other than the ARMY of ifthenelses.
Offline
Guys, SLOW DOWN! Let's talk this out a bit before rushing out with individual projects. Each individual project will have a few glitches, and together when combined we'll be left with a terrible thing. The best way to proceed from now is to first talk out how it'll work, then make a remix chain, slowly adding parts till it's perfect
.
Offline
Here.
EDIT: Comment #5 is messed up. Oh well.
Last edited by TheSuccessor (2011-04-02 08:01:54)
Offline
Well i made my middle school math team the first year (now) i am a pretty good programmer if need a little help with something
Offline
I would like to join, if possible.
I think this article will be helpful for a complicated calculator project like this. It explains what you are trying to do pretty clearly.
Basically, numbers go into a queue in a certain order, and operators go into another queue. For the purposes of this project, the system will have to distinguish between numbers and operators, as well as the (possible?) addition of user-defined variables, sqrt function, exponents, and trig functions.
Last edited by amcerbu (2011-04-02 19:20:35)
Offline
@ Recycle and amcerbu, sure, you can join!
Offline
Anybody interested in advertising, put
[url=http://scratch.mit.edu/forums/viewtopic.php?id=59599&p=1][img]http://i.imgur.com/mFo1X.png[/img][/url] [b][color=darkGrey]Thank you [url=scratch.mit.edu/users/hdarken]hdarken[/url] for the banner! Get one @ [url=http://scratch.mit.edu/forums/viewtopic.php?id=59567]his shop[/url].[/color][/b]
in your signature.
It makes:
Thank you hdarken for the banner! Get one @ his shop.
Thanks
Last edited by Hardmath123 (2011-04-03 05:39:35)
Offline
TheSuccessor wrote:
Here.
EDIT: Comment #5 is messed up. Oh well.
Bumping the bracket extractor.
Offline
TheSuccessor wrote:
TheSuccessor wrote:
Here.
EDIT: Comment #5 is messed up. Oh well.Bumping the bracket extractor.
You know, it's not nice to link to the download (unless you mention that that link will download something. Some people aren't allowed to download (like at schools), and this could get them in trouble.
Offline
amcerbu wrote:
I would like to join, if possible.
I think this article will be helpful for a complicated calculator project like this. It explains what you are trying to do pretty clearly.
Basically, numbers go into a queue in a certain order, and operators go into another queue. For the purposes of this project, the system will have to distinguish between numbers and operators, as well as the (possible?) addition of user-defined variables, sqrt function, exponents, and trig functions.
Here is my Postfix converter, based on amcerbu's suggestion.
Tell me what you think.
Offline
hpotter134 wrote:
amcerbu wrote:
I would like to join, if possible.
I think this article will be helpful for a complicated calculator project like this. It explains what you are trying to do pretty clearly.
Basically, numbers go into a queue in a certain order, and operators go into another queue. For the purposes of this project, the system will have to distinguish between numbers and operators, as well as the (possible?) addition of user-defined variables, sqrt function, exponents, and trig functions.Here is my Postfix converter, based on amcerbu's suggestion.
Tell me what you think.
I wrote:
Guys, SLOW DOWN! Let's talk this out a bit before rushing out with individual projects. Each individual project will have a few glitches, and together when combined we'll be left with a terrible thing. The best way to proceed from now is to first talk out how it'll work, then make a remix chain, slowly adding parts till it's perfect
.
I think this whole shunting yard may lead to confusion. Let's start with something simple: scanning for an operator and evaluating with the bordering numbers, or something like that. But, either way, let's slow down and talk it out first.
Offline
Hardmath123 wrote:
I wrote:
Guys, SLOW DOWN! Let's talk this out a bit before rushing out with individual projects. Each individual project will have a few glitches, and together when combined we'll be left with a terrible thing. The best way to proceed from now is to first talk out how it'll work, then make a remix chain, slowly adding parts till it's perfect
.
I think this whole shunting yard may lead to confusion. Let's start with something simple: scanning for an operator and evaluating with the bordering numbers, or something like that. But, either way, let's slow down and talk it out first.
Oops. Sorry. Got carried away.
So our main problem is parenthesis, right? Followed closely by functions. The reason the postfix (3 4 + v.s. 3+4) is useful is because it eliminates the need for parenthesis, leading to simple execution.
What other options do we have? It would be nice if we had binary trees or something like it, but we don't, so we'll have to make do with lists.
Offline
hpotter134 wrote:
Hardmath123 wrote:
I wrote:
Guys, SLOW DOWN! Let's talk this out a bit before rushing out with individual projects. Each individual project will have a few glitches, and together when combined we'll be left with a terrible thing. The best way to proceed from now is to first talk out how it'll work, then make a remix chain, slowly adding parts till it's perfect
.
I think this whole shunting yard may lead to confusion. Let's start with something simple: scanning for an operator and evaluating with the bordering numbers, or something like that. But, either way, let's slow down and talk it out first.
Oops. Sorry. Got carried away.
![]()
So our main problem is parenthesis, right? Followed closely by functions. The reason the postfix (3 4 + v.s. 3+4) is useful is because it eliminates the need for parenthesis, leading to simple execution.
What other options do we have? It would be nice if we had binary trees or something like it, but we don't, so we'll have to make do with lists.
Hmmm, but how would you do (3+4)(3-4) [your engine messed it up big time
]?
How about we use a 'scanner' type function—you 'scan' for a ')', then scan backwards for a '(', and evaluate the expression in between. Since you start with the innermost brackets, nesting won't be a problem!
e.g.
6+7*(2+2)
/scans for )/
/scans for (/
/sets a variable to all text in between/
to solve: 2+2
solves: 4
/replaces (2+2) with 4/
to solve: 6+7*4
Last edited by Hardmath123 (2011-04-04 01:02:55)
Offline
Hardmath123 wrote:
hpotter134 wrote:
Hardmath123 wrote:
I think this whole shunting yard may lead to confusion. Let's start with something simple: scanning for an operator and evaluating with the bordering numbers, or something like that. But, either way, let's slow down and talk it out first.Oops. Sorry. Got carried away.
![]()
So our main problem is parenthesis, right? Followed closely by functions. The reason the postfix (3 4 + v.s. 3+4) is useful is because it eliminates the need for parenthesis, leading to simple execution.
What other options do we have? It would be nice if we had binary trees or something like it, but we don't, so we'll have to make do with lists.Hmmm, but how would you do (3+4)(3-4) [your engine messed it up big time
]?
How about we use a 'scanner' type function—you 'scan' for a ')', then scan backwards for a '(', and evaluate the expression in between. Since you start with the innermost brackets, nesting won't be a problem!
e.g.
6+7*(2+2)
/scans for )/
/scans for (/
/sets a variable to all text in between/
to solve: 2+2
solves: 4
/replaces (2+2) with 4/
to solve: 6+7*4
Yeah, that's probably the best way to do it.
Offline
scimonster wrote:
Hardmath123 wrote:
hpotter134 wrote:
Oops. Sorry. Got carried away.![]()
So our main problem is parenthesis, right? Followed closely by functions. The reason the postfix (3 4 + v.s. 3+4) is useful is because it eliminates the need for parenthesis, leading to simple execution.
What other options do we have? It would be nice if we had binary trees or something like it, but we don't, so we'll have to make do with lists.Hmmm, but how would you do (3+4)(3-4) [your engine messed it up big time
]?
How about we use a 'scanner' type function—you 'scan' for a ')', then scan backwards for a '(', and evaluate the expression in between. Since you start with the innermost brackets, nesting won't be a problem!
e.g.
6+7*(2+2)
/scans for )/
/scans for (/
/sets a variable to all text in between/
to solve: 2+2
solves: 4
/replaces (2+2) with 4/
to solve: 6+7*4Yeah, that's probably the best way to do it.
![]()
Great, I guess we ought to program something small to test it. Sci, could you make something to find the innermost bracketed expression? (it should report 3+2 for 3+(2+(3+2)))
Meanwhile, I'll start on something to evaluate stuff without brackets.
Offline
Hardmath123 wrote:
scimonster wrote:
Hardmath123 wrote:
Hmmm, but how would you do (3+4)(3-4) [your engine messed it up big time]?
How about we use a 'scanner' type function—you 'scan' for a ')', then scan backwards for a '(', and evaluate the expression in between. Since you start with the innermost brackets, nesting won't be a problem!
e.g.
6+7*(2+2)
/scans for )/
/scans for (/
/sets a variable to all text in between/
to solve: 2+2
solves: 4
/replaces (2+2) with 4/
to solve: 6+7*4Yeah, that's probably the best way to do it.
![]()
Great, I guess we ought to program something small to test it. Sci, could you make something to find the innermost bracketed expression? (it should report 3+2 for 3+(2+(3+2)))
Meanwhile, I'll start on something to evaluate stuff without brackets.
Yes, I'll do that soon.
I should base it off hpotter134's engine?
Offline
scimonster wrote:
Hardmath123 wrote:
scimonster wrote:
Yeah, that's probably the best way to do it.![]()
Great, I guess we ought to program something small to test it. Sci, could you make something to find the innermost bracketed expression? (it should report 3+2 for 3+(2+(3+2)))
Meanwhile, I'll start on something to evaluate stuff without brackets.Yes, I'll do that soon.
I should base it off hpotter134's engine?
If you need to, though I recommend starting from Scratch (pun not intended, honestly
)
Offline
Hardmath123 wrote:
scimonster wrote:
Hardmath123 wrote:
Great, I guess we ought to program something small to test it. Sci, could you make something to find the innermost bracketed expression? (it should report 3+2 for 3+(2+(3+2)))
Meanwhile, I'll start on something to evaluate stuff without brackets.Yes, I'll do that soon.
I should base it off hpotter134's engine?
If you need to, though I recommend starting from Scratch (pun not intended, honestly
)
So I'll use your setup engine and then create the calculator.
Offline
OK, it separates the problem in 1 set of parentheses, but gets stuck in a repeat with more.
I'll work some more.
Offline
The name is pronounced "Zeenon," right?
Offline
scimonster wrote:
The name is pronounced "Zeenon," right?
![]()
|ˈzēˌnän; ˈzenˌän|
Offline
Hardmath123 wrote:
scimonster wrote:
The name is pronounced "Zeenon," right?
![]()
|ˈzēˌnän; ˈzenˌän|
?
Offline
scimonster wrote:
Hardmath123 wrote:
scimonster wrote:
The name is pronounced "Zeenon," right?
![]()
|ˈzēˌnän; ˈzenˌän|
?
Dictionary pronunciation guide.
Offline