Talk:Arithmetic evaluation: Difference between revisions

New section: D solutions
(Makes sense)
(New section: D solutions)
Line 11:
:: To be honest, I'd put it in with "riddles" more than anything. It's a pretty standars CS101 task and the generic answer says that you use two stacks, one for the numbers and one for the operators. Thus this really boils down to "implement a stack". Of course that doesn't mean that someone might not have a particularly clever solution that would teach a lot about the way some language works. (Just because I find a task uninteresting doesn't mean someone else does the same). The reason I would put this in "puzzles" is that all languages I actually use have an arithmetic evaluator built-in. Thus "assign a value to an array" is an operation I do actually perform in my code, but "parse arithmetic strings" is not.[[User:Sgeier|Sgeier]] 14:46, 24 January 2008 (MST)
:::That makes sense. It's at least ''different'' from a regular task. A prefix notation "small programming language" interpreter (with just addition and multiplication and strings) was actually a project for my CS3 class (the CS classes are 200-level at my school). We did it using a tree rather than a stack, but that was for prefix notation. --[[User:Mwn3d|Mwn3d]] 14:51, 24 January 2008 (MST)
 
== D solutions ==
 
The first solution doesn't respect operator precedence properly. There may be other bugs. And neither solution actually builds the AST. --[[User:Naryl|Naryl]] 17:29, 29 January 2008 (MST)
Anonymous user