how to parse a string into real equation in netlogo

时光毁灭记忆、已成空白 提交于 2019-12-14 02:27:17

问题


I am trying to develop a model in netlogo, in which user can enter the equation for change in some variables. My question is what could be the best way to get equation input and how should i parse it and calculate results. looking for something like "mathml" which could work in netlogo.


回答1:


A simple solution that doesn't involve MathML or anything of the sort would be to have your users directly enter NetLogo expressions and run those using runresult, which can take a string of NetLogo code and execute it.

Here is a simple example that uses an input box widget (with the type "String (reporter)") to allow the user to enter an arbitrary mathematical expression. The button prints the result of running the expression in the output box:

In a real world application, of course, you would have to be very careful about error handling.



来源:https://stackoverflow.com/questions/45295683/how-to-parse-a-string-into-real-equation-in-netlogo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!