This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#76 2011-04-01 15:58:14

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Calling all math lovers and good programmers

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.


/* No comment */

Offline

 

#77 2011-04-01 20:13:53

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Calling all math lovers and good programmers

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.


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#78 2011-04-02 06:53:55

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

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  wink  .


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#79 2011-04-02 08:00:41

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Calling all math lovers and good programmers

Here.

EDIT: Comment #5 is messed up. Oh well.

Last edited by TheSuccessor (2011-04-02 08:01:54)


/* No comment */

Offline

 

#80 2011-04-02 08:40:59

recycle49
Scratcher
Registered: 2009-12-21
Posts: 1000+

Re: Calling all math lovers and good programmers

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


"Every challenge must be met, every battle must be won, and every story will end." -Me
Recycle49 December 09 - November 11 Goodbye

Offline

 

#81 2011-04-02 16:32:09

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

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

 

#82 2011-04-03 02:06:47

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

@ Recycle and amcerbu, sure, you can join!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#83 2011-04-03 05:32:10

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

Anybody interested in advertising, put

Code:

[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:

http://i.imgur.com/mFo1X.png
Thank you hdarken for the banner! Get one @ his shop.

Thanks  smile

Last edited by Hardmath123 (2011-04-03 05:39:35)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#84 2011-04-03 05:50:55

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Calling all math lovers and good programmers

TheSuccessor wrote:

Here.

EDIT: Comment #5 is messed up. Oh well.

Bumping the bracket extractor.


/* No comment */

Offline

 

#85 2011-04-03 07:24:37

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

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.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#86 2011-04-03 11:10:33

hpotter134
Scratcher
Registered: 2010-02-21
Posts: 100+

Re: Calling all math lovers and good programmers

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.


http://i45.tinypic.com/fxgtvc.png

Offline

 

#87 2011-04-03 12:17:43

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

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  smile .

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.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#88 2011-04-03 12:26:03

applejack
Scratcher
Registered: 2010-03-23
Posts: 100+

Re: Calling all math lovers and good programmers

I am ADVERTIZING!!! I haz mad 2 apps for da iPhone so far.  big_smile


http://i.imgur.com/zKzps.png
http://blocks.scratchr.org/API.php?action=onlineStatus&type=square&user=applejack -I'm http://blocks.scratchr.org/API.php?action=onlineStatus&type=text&user=applejack

Offline

 

#89 2011-04-03 12:26:22

hpotter134
Scratcher
Registered: 2010-02-21
Posts: 100+

Re: Calling all math lovers and good programmers

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  smile .

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.  big_smile

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.


http://i45.tinypic.com/fxgtvc.png

Offline

 

#90 2011-04-04 01:00:22

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

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  smile .

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.  big_smile

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  hmm  ]?

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)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#91 2011-04-04 04:13:58

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

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.  big_smile

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  hmm  ]?

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.  smile

Offline

 

#92 2011-04-04 06:14:55

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

scimonster wrote:

Hardmath123 wrote:

hpotter134 wrote:


Oops. Sorry. Got carried away.  big_smile

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  hmm  ]?

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.  smile

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.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#93 2011-04-04 06:24:52

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

Hardmath123 wrote:

scimonster wrote:

Hardmath123 wrote:


Hmmm, but how would you do (3+4)(3-4) [your engine messed it up big time  hmm  ]?

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.  smile

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.  smile  I should base it off hpotter134's engine?

Offline

 

#94 2011-04-04 06:32:52

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

scimonster wrote:

Hardmath123 wrote:

scimonster wrote:


Yeah, that's probably the best way to do it.  smile

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.  smile  I should base it off hpotter134's engine?

If you need to, though I recommend starting from Scratch (pun not intended, honestly  big_smile )


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#95 2011-04-04 06:41:50

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

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.  smile  I should base it off hpotter134's engine?

If you need to, though I recommend starting from Scratch (pun not intended, honestly  big_smile )

So I'll use your setup engine and then create the calculator.

Offline

 

#96 2011-04-04 07:30:22

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

OK, it separates the problem in 1 set of parentheses, but gets stuck in a repeat with more.  hmm  I'll work some more.

Offline

 

#97 2011-04-04 07:36:51

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

The name is pronounced "Zeenon," right?  tongue

Offline

 

#98 2011-04-04 09:15:52

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

scimonster wrote:

The name is pronounced "Zeenon," right?  tongue

|ˈzēˌnän; ˈzenˌän|


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#99 2011-04-04 09:19:58

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

Hardmath123 wrote:

scimonster wrote:

The name is pronounced "Zeenon," right?  tongue

|ˈzēˌnän; ˈzenˌän|

?

Offline

 

#100 2011-04-04 09:20:45

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

scimonster wrote:

Hardmath123 wrote:

scimonster wrote:

The name is pronounced "Zeenon," right?  tongue

|ˈzēˌnän; ˈzenˌän|

?

Dictionary pronunciation guide.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

Board footer