问题
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