|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% {2 S/ B& ?# X' d其中有一段如下
5 a" E$ o, s: U3 T* ~; qask turtles with [ infected? = true ] ( ]0 p# f2 G! I4 V% G) E
我原本以为这句会回传『所有』infected? = true 的 turtle
6 g& L6 T9 N& \ ~但看结果似乎不是这样。2 ?3 D6 `1 {9 W" M0 H* s' |
/ [2 @8 a& O. n" U2 v假设所有符合条件的有 5 笔5 t0 i/ E# N6 g1 f0 _) s5 i
有时候回传 1 笔,有时回传 3 笔,是不固定的& x2 L3 N4 B+ ]
回头查语法定义
) G. p/ Y. O& s5 M4 H8 dwith
8 Z. A3 s5 w G" B1 w( g/ xagentset with [reporter]$ T0 \+ t; t, w) S0 F+ F' U
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.
4 C/ o* Z" C# ^' w. ~: q它只说回传 agents satisfying the given condition& r5 m9 F2 \3 {( t0 `5 G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % m! E: ?; y" [; i$ I; ~
# w: G/ }& }( r8 ?% ]' j想确定一下
+ f% g) i: \6 r3 z: l* H' N谢谢!8 p, x% c0 a6 \8 @; s1 q% U, K
|
|