|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序, H$ N, s k. [8 h4 ?" ]
其中有一段如下5 j6 P( x4 B: Q7 N5 O( r, E
ask turtles with [ infected? = true ]
' ?9 C8 W t. j3 |我原本以为这句会回传『所有』infected? = true 的 turtle
& Z) m. W# H1 T j但看结果似乎不是这样。
p1 S- U# I9 ?" X
0 H7 S3 P0 t5 }( {0 I假设所有符合条件的有 5 笔0 ?4 u1 {1 I( K2 |4 A3 I
有时候回传 1 笔,有时回传 3 笔,是不固定的) L' ^* a; {+ b- r/ \
回头查语法定义1 I3 S1 `8 X) k$ C8 n9 B$ Z" q
with # o! ]0 S6 s, P: }) i
agentset with [reporter]* B# x$ D3 f/ T+ J
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.# q3 `( ^9 C# e) [0 H9 y+ M
它只说回传 agents satisfying the given condition) C. o2 D3 }7 P* l w
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
. o+ a Q& P# H, e* N2 z
2 j! i, m- x/ \- l想确定一下
y: k1 F* F1 k: F谢谢!: V' r! k1 k1 e# g; D* n; M
|
|