def rpn(str)
  a=[]
  ops = {
    '^' => ->(x,y){x**y},
  }

  str.split.each do |x|
    if x =~ /\d+(\.\d+)?/
      a.push x.to_f
    else
      l, r = a.pop 2
      a.push ops[x] ? ops[x].(l,r) : l.send(x,r)
    end
  end
  a
end

puts rpn('10.2 2 + 14 - 4 + 2 ^')

def rpn(str)
  a=[]
  ops = {
    '^' => ->(x,y){x**y},
  }

  str.split.each do |x|
    if x =~ /\d+(\.\d+)?/
      a.push x.to_f
    else
      l, r = a.pop 2
      a.push ops[x] ? ops[x].(l,r) : l.send(x,r)
    end
  end
  a
end

puts rpn('10 2 + 14 - 4 + 2 ^ 0.2 +')

Add a test for floats and such.
Add a test for floats and such.
