使代理商不在列表中 [英] Making agentset outof list

查看:229
本文介绍了使代理商不在列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何将列表(代表海龟)转换为代理集?



例如,我想制作包含4个元素[turtle 0 turtle 3 turtle 4 turtle 7]的

agentset



out of list [turtle 0turtle 3turtle 4turtle 7]
$ b foreach之前。

提前谢谢〜!

解决方案

我不确定为什么您需要使用像

这样的列表

  [turtle 0turtle 3turtle 4turtle 7] 

$首先是b
$ b

。如果没有直接引用代理的话,存储代理的引用通常不是一个好主意。

这就是说,你可以将这样的字符串转换为一个代理集:



pre $ turtle-set map runresult [turtle 0turtle 3turtle 4turtle 7]

如果这些海龟中的任何一个不存在,它们将被排除在最终的代理集之外。



尽管如此,整个事情让我觉得有些不妥。如果你告诉我们更多关于你想要完成的事情,也许我们可以建议一个更好的方法。


This is relevant to the previous question just asked.

How can I convert list(which representing turtles) to a agentset?

For example, I want to make

agentset which contains 4 elements [turtle 0 turtle 3 turtle 4 turtle 7]

out of list ["turtle 0" "turtle 3" "turtle 4" "turtle 7"]

I've tried "foreach" before.

Thank you in advance~!!

解决方案

I am not sure why you would need to work with a list like

["turtle 0" "turtle 3" "turtle 4" "turtle 7"]

in the first place. Storing references to agents as anything other than direct references to the agents is usually not a good idea.

That being said, you can convert such a string to an agentset with:

turtle-set map runresult ["turtle 0" "turtle 3" "turtle 4" "turtle 7"]

If any of those turtles don't exist, they will just be excluded from the resulting agentset.

Still, the whole thing strikes me as somewhat ill advised. If you tell us more about what you're trying to accomplish, maybe we could suggest a better approach altogether.

这篇关于使代理商不在列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆