user7973134
user7973134

Reputation:

Netlogo arrays need literal values

The array is expecting a literal value

set chrom [forage_min forage_rate share_min share_rate mating_treshold]
        print chrom

How can I handle it? I really don't understand arrays in Netlogo.

Upvotes: 1

Views: 4569

Answers (1)

Nicolas Payette
Nicolas Payette

Reputation: 14972

(You speak of "arrays" in your question, but I think you mean "lists". It is possible to use arrays in NetLogo via the array extension, but unless you have very specific needs, that's probably not what you want. So, assuming that you are trying to create a list:)

The square bracket syntax for declaring lists only works with "literal" values, e.g., raw strings or numbers. If you want to build a list out of variables or more complex expressions, you need to use the list primitive. In your case, that would be something like:

set chrom (list forage_min forage_rate share_min share_rate mating_treshold)

I would encourage you to read the Lists section of the NetLogo programming guide.

Upvotes: 2

Related Questions