回答編集履歴
2
修正
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
|
27
|
+
もう少しひねって次のようにすることも可能でしょう。はおすすめできませんが、とにかく動きます。
|
28
28
|
|
29
29
|
|
30
30
|
|
@@ -54,16 +54,20 @@
|
|
54
54
|
|
55
55
|
```
|
56
56
|
|
57
|
-
f(x1, x2, x3, x4) = x1 + 2*x2 + x3
|
57
|
+
f(x1, x2, x3, x4) = x1 + 2*x2 + x3^2 - sin(x4)
|
58
58
|
|
59
59
|
```
|
60
60
|
|
61
61
|
|
62
62
|
|
63
|
-
のように記述したいとなると、構文を決めて構文解析を書いた方が理にかなったアプローチです。
|
63
|
+
のように記述したいとなると、構文を決めて構文解析器を書いた方が理にかなったアプローチです。
|
64
64
|
|
65
65
|
|
66
66
|
|
67
67
|
参考になりそうなリンク
|
68
68
|
|
69
69
|
[python - Evaluating a mathematical expression in a string - Stack Overflow](https://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
とはいえ、構文解析器を作るのは手間なので、どうしたものか。安全で簡単な方法はすぐには思いつきません。
|
1
追記
test
CHANGED
@@ -61,3 +61,9 @@
|
|
61
61
|
|
62
62
|
|
63
63
|
のように記述したいとなると、構文を決めて構文解析を書いた方が理にかなったアプローチです。
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
参考になりそうなリンク
|
68
|
+
|
69
|
+
[python - Evaluating a mathematical expression in a string - Stack Overflow](https://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string)
|