2009-10-03 62 views

回答

2

"ln(5*x)".sub('ln','Math.log') #=> "Math.log(5*x)"

+0

一点都不差哦 – gmile 2009-10-03 19:41:26

0
"math.log(#{"ln(5*x)"[/ln\((.*)\)/,1]})" 
+0

好了,现在,没有任何宝石或库概括出解决方案,改造所有的数学类字符串到他们的Ruby表达式表示(所有的数学词缀)? – gmile 2009-10-03 07:57:45

+0

你最好在github.com上搜索 – khelll 2009-10-03 07:58:30

+0

它们只是字符串:把它们当作字符串对待。它们看起来像数学函数并不重要。 – 2009-10-03 22:50:00