如何更改 NetLogo 中列表的第 n 项?
How to change the n-th item of a list in NetLogo?
我是 NetLogo 的新手,我正在尝试编写代码来列出所有海龟的一个海龟参数,并在每一步中更改该列表。但是由于列表中的某些项目应该被修改并且我处理它们在列表中的位置,我想知道有人可以帮助我如何编写代码来更改该列表的第 n 项(我认为 replace-item 确实不工作)。
谢谢
replace-item
命令创建一个新列表:
to test
let lst01 [0 1 2 3]
let lst02 replace-item 0 lst01 99
print (word "the first list is unchanged: " lst01)
print (word "the new list is: " lst02)
end
我是 NetLogo 的新手,我正在尝试编写代码来列出所有海龟的一个海龟参数,并在每一步中更改该列表。但是由于列表中的某些项目应该被修改并且我处理它们在列表中的位置,我想知道有人可以帮助我如何编写代码来更改该列表的第 n 项(我认为 replace-item 确实不工作)。
谢谢
replace-item
命令创建一个新列表:
to test
let lst01 [0 1 2 3]
let lst02 replace-item 0 lst01 99
print (word "the first list is unchanged: " lst01)
print (word "the new list is: " lst02)
end