|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
' E- d4 k( C# |% Q2 W: K5 P+ B其中有一段如下
3 H H& }" q5 Uask turtles with [ infected? = true ] ' S7 ]4 r0 h) d9 o
我原本以为这句会回传『所有』infected? = true 的 turtle: f3 B. y5 D) g* L# p' g/ P6 Z$ q
但看结果似乎不是这样。
, x+ }& p$ w( n$ x" ]3 e
* U6 ?) M: R, }! C9 e) B- T假设所有符合条件的有 5 笔
0 C- y. ?' C: }有时候回传 1 笔,有时回传 3 笔,是不固定的
Q9 z; `# r, _1 B, A, R回头查语法定义
2 N* t& g% L( g; t+ V7 {with + [$ `3 g4 o! L1 {6 s9 B) |
agentset with [reporter]
% M( T: h- u; \( S1 GTakes 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.
/ z- Y, f0 ]8 a它只说回传 agents satisfying the given condition
3 J! t6 N5 t! P* Z' ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / A0 ^: a4 E, W2 K% S5 ` G4 w3 F
: R. [! F. p# g/ M
想确定一下
" d+ J! W$ {5 ~! E% O# [5 ]谢谢!" T) h9 T; a5 B7 x* y+ V
|
|