2009-10-03 75 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