Can you compile a string for a task in NetLogo?

For example,

let procedure string-to-task "print ?"
(run procedure "hello")

There are several reasons why you would like to do this:

  • Tasks do not need to be recompiled, while lines are sometimes executed (especially when using a large number of them).
  • You cannot pass arguments when trying to run a string.
+4
source share
1 answer

Are you sure you can! Using this one weird only obvious trick:

to-report string-to-task [s]
  report runresult (word "task [" s "]")
end

Please note that this will return a reporter or team task depending on the contents of the input string.

+4
source

Source: https://habr.com/ru/post/1525346/


All Articles