Skip to content

Instantly share code, notes, and snippets.

@heftig
Created February 8, 2012 02:19
Show Gist options
  • Save heftig/1764569 to your computer and use it in GitHub Desktop.
Save heftig/1764569 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
until (words = gets.chomp.split).empty?
stack = []
words.each do |w|
begin
stack.push Float(w)
rescue ArgumentError
args = stack.pop(Float.instance_method(w).arity + 1)
stack.push args.first.send(w, *args[1..-1])
end
end
puts stack.join(" ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment