replace-item

replace-item index list value
replace-item index string1 string2

On a list, replaces an item in that list. index is the index of the item to be replaced, starting with 0. (The 6th item in a list would have an index of 5.) Note that "replace-item" is used in conjunction with "set" to change a list.

Likewise for a string, but the given character of string1 removed and the contents of string2 spliced in instead.

show replace-item 2 [2 7 4 5] 15
=> [2 7 15 5]
show replace-item 1 "cat" "are"
=> "caret"

Take me to the full NetLogo Dictionary