Skip to content

Instantly share code, notes, and snippets.

@heftig
Created February 8, 2012 02:19
#!/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