Loading ...
Sorry, an error occurred while loading the content.
 

RE: [netlogo-users] arrays in Netlogo

Expand Messages
  • Torbjörn Söderberg
    ... 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
    Message 1 of 4 , Apr 1, 2003
      Kazmer Karadi wrote at Monday, March 31, 2003 7:22 AM:
      > Can somebody help me? How can I define arrays in Netlogo?
      > Thanks!
      >
      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

      http://ccl.northwestern.edu/netlogo/docs/programming.html#lists

      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,

      T Söderberg
    • KazmerKaradi@netscape.net
      thanks, it is very good idea. kazi __________________________________________________________________ Try AOL and get 1045 hours FREE for 45 days!
      Message 2 of 4 , Apr 2, 2003
        thanks, it is very good idea.
        kazi

        __________________________________________________________________
        Try AOL and get 1045 hours FREE for 45 days!
        http://free.aol.com/tryaolfree/index.adp?375380

        Get AOL Instant Messenger 5.1 for FREE! Download Now!
        http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
      • Seth Tisue
        ... KazmerKaradi Hello Everybody! Can somebody help me? How can I define KazmerKaradi arrays in Netlogo? Thanks! To add to the helpful responses already
        Message 3 of 4 , Apr 3, 2003
          >>>>> "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
          Northwestern University
        Your message has been successfully submitted and would be delivered to recipients shortly.