Replace-item takes the item number (i.e. the index) of the item to be
replaced in the list, the list itself, and the *value* to replace that
item with. You are providing the *value* of the item... and--well,
I'm not sure what your placeholder "item" stands for.
Try this:
;; get a random index number
;; get and increment the item at that location
;; replace the item at that index with the incremented value
let index random (length the-list)
let new-value 1 + ( item index the-list )
set the-list replace-item index the-list new-value
Hope that helps!
~~James
http://www.turtlezero.com
On 5/14/07, ts273683 < ts273683%40yahoo.de">ts273683
yahoo.de> wrote:
> Dear netlogo-users,
>
> I have a question about how I can change the value of an item in a list.
> Especially I would like to increase the value of an item in a list
> randomly by 1, e.g. list before: [0 1 2 0], list after [0 1 3 0] or [1
> 1 2 0]
> I tried the replace-item command but couldn't make it work.
>
> "set list replace-item (one-of list) [list] (item + 1)"
>
> Does anybody could give an advice how to do it.
>
> Thanks a lot.
.