The Meaning of Life, the Universe, and Everything.
Join Date:
3/24/2013
Posts:
140
Location:
Australia
Minecraft:
sebagius7110
Member Details
Hey guys seb here I just wanted to ask if anyone wants to program together in c sharp or java, you will need skype so I can message you the download links, etc. I just wanted to see if anyone wants to program, I will add you to my shared dropbox folders, and we can program together.
Happy Programming and Playing Minecraft
-Seb
also my skype username is sebagius7110
Rollback Post to RevisionRollBack
To me The meaning of Life and the Universe is Everything.
I'll post an idea for stuff for you guys to create, simple command line stuff, and we see who can do it with decent code. Prefer submittals through GitHub.
First assignment:
A simple calculator program that parses equations from prefix notation, calculates using a tree, and prints the answer, infix notation, and postfix notation.
My question is why you'd use a tree for parsing polish notation instead of just a stack.
Implementing as a stack would require slightly more work to handle PEMDAS situations, depending how you implement your data nodes. I'd likely parse the input equation string using a stack, but would probably convert to a tree to store the actual equation. It's a fairly simple solution.
Using a Node as the base structure, I'd implement a base Node class that defines that all Node objects have a LeftNode var, RightNode var, and a Calculate() method. It'd be fairly simple to just call the Calculate method on any Node in the tree and it would return the value for that subset of the equation. Could define different behaviors, such as variable nodes returning the value of a variable from a dictionary, or an add node that returns the sum of its Left and Right nodes.
Implementing as a stack would require slightly more work to handle PEMDAS situations, depending how you implement your data nodes. I'd likely parse the input equation string using a stack, but would probably convert to a tree to store the actual equation.
It doesn't currently support infix input or removal of unnecessary parenthesis in infix output. That'll be a bit more difficult since it involves order of operations, but I'll try. Also the code's an undocumented mess, but I think the algorithm itself is rather elegant. With some work I think I could make a generic ParseTree package good enough to release into the wild to be used elsewhere.
Happy Programming and Playing Minecraft
-Seb
also my skype username is sebagius7110
To me The meaning of Life and the Universe is Everything.
-sebagius7110 2014
This thread is a trainwreck already at only two posts...
I need to learn everything again. Life got in the way and I haven't been able to in a very long time. What do you plan on making?
Build Planes, Boats, Cars, Airships and fight!
I took an AP Computer Science course during my Junior year in high school and know very basic Java, but I'm interested in this.
What are your plans?
I have an idea.
I'll post an idea for stuff for you guys to create, simple command line stuff, and we see who can do it with decent code. Prefer submittals through GitHub.
First assignment:
A simple calculator program that parses equations from prefix notation, calculates using a tree, and prints the answer, infix notation, and postfix notation.
Aaaanndddd.... go!
"Programmers never repeat themselves. They loop."
My question is why you'd use a tree for parsing polish notation instead of just a stack.
I do not understand what you mean be all these "notations" lol and calculates using a tree?
I could make a simple calculator in Eclipse, fairly easily though.
Implementing as a stack would require slightly more work to handle PEMDAS situations, depending how you implement your data nodes. I'd likely parse the input equation string using a stack, but would probably convert to a tree to store the actual equation. It's a fairly simple solution.
Using a Node as the base structure, I'd implement a base Node class that defines that all Node objects have a LeftNode var, RightNode var, and a Calculate() method. It'd be fairly simple to just call the Calculate method on any Node in the tree and it would return the value for that subset of the equation. Could define different behaviors, such as variable nodes returning the value of a variable from a dictionary, or an add node that returns the sum of its Left and Right nodes.
Would you approach it differently?
"Programmers never repeat themselves. They loop."
Okay, I missed the part about printing as infix.
Yeah I did take AP Computer Science and I made a 4 on the AP Exam...that stuff might not have been in the curriculum.
https://github.com/Stuntddude/Polish
It doesn't currently support infix input or removal of unnecessary parenthesis in infix output. That'll be a bit more difficult since it involves order of operations, but I'll try. Also the code's an undocumented mess, but I think the algorithm itself is rather elegant. With some work I think I could make a generic ParseTree package good enough to release into the wild to be used elsewhere.