[Tutor] Simple RPN calculator

Max Noel maxnoel_fr at yahoo.fr
Sun Dec 5 00:45:18 CET 2004


On Dec 4, 2004, at 23:30, Alan Gauld wrote:

>> to make it request for input(s) of say a simple math like  "1 2 3 4
> 5 + - * /".
>
> Look at raw_input()
>
> But if you are that much of a beginner you need to take several
> steps back and try one of the tutorials, they all cover raw_input
> fairly early on...
>
> And finally doesn't RPN put the operators first? Or is it me thats
> getting confused fromtoo much Lisping recently?...

	Nope, RPN calculators (such as the HP48GX, IMHO the best calculator 
ever made) require you to input the operands first, then the operators. 
It's both easier to implement and more intuitive (not to mention way 
faster to both input and compute) once you've gotten the hang of it.
	You can probably do a very basic RPN calculator in less than a hundred 
lines of code, using raw_input() and a stack (well, a list's append() 
and pop() methods).

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?"



More information about the Tutor mailing list