TA_Kosice
TA_Kosice

Reputation: 13

Netlogo: Iterating Over Lists

I would like to use this part of code in NetLogo:

foreach [2 4 6]
  [ crt ?
    show "created " + ? + " turtles" ]

It comes from documentation – Iterating over lists. But when I run code, this error message displays:

expected this input to be a number, but got a string instead

If I leave + from show command, then there is no error, but therefore I cannot write iteration number. Where is problem?

Upvotes: 0

Views: 2047

Answers (1)

RobinCura
RobinCura

Reputation: 410

You probably use a newer version of NetLogo (this is the help for Netlogo 2.x) Check the new example here : http://ccl.northwestern.edu/netlogo/5.0/docs/programming.html#lists

And the associated code :

  foreach [2 4 6]
  [
    crt ?
    show (word "created " ? " turtles")
  ]

Upvotes: 1

Related Questions