Skip to content

Instantly share code, notes, and snippets.

@kejadlen
Created July 25, 2012 15:18
Show Gist options
  • Save kejadlen/3176737 to your computer and use it in GitHub Desktop.
Save kejadlen/3176737 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
puts ARGV[0].split(/\s*/).inject([]) {|n,i|
n << ((%w[+ - * /].include?(i)) ? (b,a=n.pop,n.pop; "(#{a} #{i} #{b})") : i)
}[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment