Using functions as variables in Julia
In Julia, programming language functions are first-class objects that can be processed and passed as parameters to other functions. This allows for great flexibility in the language syntax.
In this recipe, we will show how to use Julia to manipulate a collection ofstruct
objects to carry out a simplified multi-agent simulation model.
Getting ready
For this recipe, no package installation is required. Firstly, start the Julia command line.
In this recipe, we use random numbers—if you want to get exactly the same results such as the ones shown in this recipe, set the random seed value to0
:
usingRandom Random.seed!(0);
Note
In the GitHub repository for this recipe you will find the commands.txt
file that contains the presented sequence of Julia commands.
How to do it...
In this example, we will consider a simplified agent-based simulation model, where a group of agents moves randomly over a two-dimensional surface. Additionally, we assume that, at each step of the...