Skip to content

Instantly share code, notes, and snippets.

View ryanhburbank's full-sized avatar

Ryan ryanhburbank

  • Moxie
  • Second star on the right, straight on 'till morning
View GitHub Profile
@ryanhburbank
ryanhburbank / burbank_rpn.rb
Created July 2, 2013 15:11
Reverse Polish Calculator first implementation
#calc = RPNCalculator.new
#calc.evaluate('1 2 +') # => 3
#calc.evaluate('2 5 *') # => 10
#calc.evaluate('50 20 -') # => 30
# The general rule is that 'A B op' is the same as 'A op B'
# i.e., 5 4 - is 5 - 4.
#calc.evaluate('70 10 4 + 5 * -') # => 0