Ruby, 24
r=eval s.gsub ?/,'**-1*'
Thank you to @ybeltukov for the Mathematica technique. I "knew" there was a substitution that could be used to leverage eval
and yours was much simpler than the regexes I was trying!
r=eval s.gsub ?/,'**-1*'
Thank you to @ybeltukov for the Mathematica technique. I "knew" there was a substitution that could be used to leverage eval
and yours was much simpler than the regexes I was trying!