|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
. N$ ^7 {( x8 R9 F8 Q8 A其中有一段如下
]! K! n' X( N4 h7 } ^ask turtles with [ infected? = true ]
4 Q% |* N+ W$ S' {( J" Y我原本以为这句会回传『所有』infected? = true 的 turtle2 V* h$ d7 W7 P% k1 H0 F
但看结果似乎不是这样。1 g. T5 Y! d5 h* J7 f) O- q5 b/ ^
0 J+ }: Z8 t C* y8 h9 N
假设所有符合条件的有 5 笔- r0 V9 z2 E/ |
有时候回传 1 笔,有时回传 3 笔,是不固定的+ @) @1 C# T6 ~ k+ P* E; V! |" e
回头查语法定义0 |% R6 L" i2 s9 t, {" k! x
with " R+ r/ _* T+ H w- V. L" Z
agentset with [reporter]
5 R* S; E9 m& _Takes two inputs: on the left, an agentset (usually "turtles" or "patches"). On the right, a boolean reporter. Reports a new agentset containing only those agents that reported true -- in other words, the agents satisfying the given condition.
6 R$ p0 S* T3 G/ V; [它只说回传 agents satisfying the given condition% S1 @/ z+ u( ~& ` R( v
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
6 S$ m: O: e# t! q# [+ S' l9 ]) \) f3 K- x4 c; P3 L
想确定一下
$ J4 d% D" H! F+ T( I7 P' S" y谢谢!
$ q3 ]# C: l% f7 [0 ]4 X p |
|