A Simple Conversion
- Input: 3+4
- Add 3 to the output queue (whenever a number is read it is added to the output)
- Push + (or its ID) onto the operator stack
- Add 4 to the output queue
- After reading the expression pop the operators off the stack and add them to the output.
- In this case there is only one, "+".
- Output 3 4 +
This already shows a couple of rules:
- All numbers are added to the output when they are read.
- At the end of reading the expression, pop all operators off the stack and onto the output.
Read more about this topic: Shunting-yard Algorithm
Famous quotes containing the words simple and/or conversion:
“What have Massachusetts and the North sent a few sane representatives to Congress for, of late years?... All their speeches put together and boiled down ... do not match for manly directness and force, and for simple truth, the few casual remarks of crazy John Brown on the floor of the Harpers Ferry engine-house,that man whom you are about to hang, to send to the other world, though not to represent you there.”
—Henry David Thoreau (18171862)
“The conversion of a savage to Christianity is the conversion of Christianity to savagery.”
—George Bernard Shaw (18561950)