RE: [netlogo-users] arrays in Netlogo
- Kazmer Karadi wrote at Monday, March 31, 2003 7:22 AM:
> Can somebody help me? How can I define arrays in Netlogo?It depends on what you want them for, but I guess the most
straightforward way is to use lists. Use a list of
values for a 1-dimensional array, a list of lists for
2-dimensional etc. The item and replace-item operators
lets you access arbitrary elements but I am not sure it is
very efficient. Read more on
If the data is related directly to the model the pathches and
agent sets of course implicitly define suitable arrays and
operators on them.
Hope this helps,
- thanks, it is very good idea.
Try AOL and get 1045 hours FREE for 45 days!
Get AOL Instant Messenger 5.1 for FREE! Download Now!
>>>>> "KazmerKaradi" == KazmerKaradi <KazmerKaradi@...> writes:KazmerKaradi> Hello Everybody! Can somebody help me? How can I define
KazmerKaradi> arrays in Netlogo? Thanks!
To add to the helpful responses already posted...
What NetLogo calls "lists" are actually implemented internally as
arrays, so they have most of the performance characteristics of arrays
-- for example, random access (using the "item" reporter) is
constant-time. However, they're immutable arrays, so replace-item is
linear-time, not constant-time (because the whole array is copied).
For most purposes, the differences between lists and arrays doesn't
matter; it only matters if you're dealing with very long lists/arrays.
In a future version of NetLogo (probably not 1.3, hopefully 1.4) we plan
to change our lists to be ordinary singly linked lists like other Logo
(and Lisp) implementations have -- at the same time, we will also
provide arrays as a separate data type.
Seth Tisue / seth@... / (847) 467-2814
lead developer, NetLogo http://ccl.northwestern.edu/netlogo/
Center for Connected Learning and Computer-Based Modeling
School of Education and Social Policy / Department of Computer Science