| Sunnan 2005-04-21, 4:00 am |
| Abdulaziz Ghuloum wrote:
> Here is another rpn (also with no error handling, interactivity, ...).
> It also assumes that all operators are binary.
> Also, this rpn has no side effects.
Yours is pure functional, but mine doesn't have any external
side-effects (does that phrasing make sense?). I *used* bangs internally
for brevity, but my rpn still just take stuff in, and put stuff out. I'd
still use it in an otherwise pure functional program. I toyed with
something that looked like your program for a while before things
settled down, and my factorings were made.
I actually found the pure functional version harder to debug/grok as I
was writing it; it juggles a lot more state around, explicitly, and it's
longer.
An interesting property of your program is that it's iterative, mine is
recursive. (And the fact that it had to be *reverse* polish notation
complicated my program (remove the reverse line and switch b and c, and
call it pn), while yours work with it.)
I guess you always think the version you write yourself looks the
clearest...
|