NetLogo Help: run runresult

### run1.3 runresult1.3

#### run command (run command input1 ...) run string runresult reporter (runresult reporter input1 ...) runresult string

The `run` form expects the name of a command, an anonymous command, or a string containing commands. This agent then runs them.

The `runresult` form expects the name of a reporter, an anonymous reporter, or a string containing a reporter. This agent runs it and reports the result.

Note that you can't use `run` to define or redefine procedures. If you care about performance, note that the code must be compiled first which takes time. However, compiled bits of code are cached by NetLogo and thus using `run` on the same string over and over is much faster than running different strings. The first run, though, will be many times slower than running the same code directly, or in an anonymous command.

Anonymous procedures are recommended over strings whenever possible. (An example of when you must use strings is if you accept pieces of code from the user of your model.)

Anonymous procedures may freely read and/or set local variables and procedure inputs. Trying to do the same with strings may or may not work and should not be relied on.

When using anonymous procedures, you can provide them with inputs, if you surround the entire call with parentheses. For example:

    (run [ [turtle-count step-count] -> crt turtle-count [ fd step-count ] ] 10 5)
    ;; creates 10 turtles and move them forward 5 steps
    show (runresult [ [a b] -> a + b ] 10 5)
    => 15
    ;; adds 10 and 5

See also foreach, -> (anonymous procedure).

Take me to the full NetLogo Dictionary