Ahmed Al-Jaishi
Ahmed Al-Jaishi

Reputation: 23

In NetLogo 6.1: how do I find the property of sorted turtles?

I am a new NetLogo user. How do I get the property of sorted turtles?

clear-all

create-turtles 5

foreach (sort turtles) [ask ? [show who]]

However, the above code produces the error below

ERROR: Nothing named ? has been defined.

Upvotes: 1

Views: 39

Answers (1)

Charles
Charles

Reputation: 4168

The syntax of foreach changed with NetLogo 6 and the question mark syntax is no longer supported. The proper syntax is shown at https://ccl.northwestern.edu/netlogo/docs/dictionary.html#foreach

So, in your case the command would be

foreach (sort turtles) [n -> ask n [show who]]

where "n" is taking on the role of the old "?".

Check out the description of anonymous procedures in the NelLogo dictionary at https://ccl.northwestern.edu/netlogo/docs/dictionary.html#arrow

Charles

Upvotes: 1

Related Questions