John La Rooy larooy.com> writes: > > The third line doesn't look equivalent to me, shouldn't it be: > > 2 3 + 4 * 1 + > Writing it that way uses less space on the stack. It's only equivalent > when '+' represents a commutative operation - which is the usual case > of course. Actually, no. Normally if the operands are literals then the reduction will compute them and put the result on the result stack immediately while parsing. If the operands are not literals then it may be a real compiler and then additional optimization must be done on the finished rpn string, to reduce all possible constants. So it does not necessarily increase the stack size to write it as is, but it may complicate the shunting yard algorythm a lot to do so, so it is done in another step after the shunting yard is done. Peter -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist