[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Reverse Polish Ruby

jjthrash

10/20/2006 2:07:00 PM

Hey folks,

So.. all I wanted was an RPN calculator. So I wrote one. But, I
thought, why should I reimplement +? Or -, sin, etc? So I decided to
pass those requests along to Ruby. After that, my coworker joined in
and we went a little overboard.

The resulting monstrosity is a gruesome combination of object oriented
programming language and Reverse Polish Notation. For example: "2 1 +"
yields 3, right? It's really doing 2.send(:+, 1).

Feel free to try it out. I kinda like it. But don't say I didn't warn
you it was gruesome. At least it's a usable RPN calculator, and it's
fun that "1 1 { dup2 + } 10 evaln" gives you the first 12 numbers of
the Fibonacci sequence.

gem install rprb --source http://gems.jimmyth...

Jimmy