|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 p5 m8 ]( s$ J& X) F
其中有一段如下
t% c. }& {0 Uask turtles with [ infected? = true ] 5 @4 n) a& i9 o: [5 Z6 I# s
我原本以为这句会回传『所有』infected? = true 的 turtle+ j, V9 ]! ~: U3 W! g! C9 b" k
但看结果似乎不是这样。' \8 h* F8 d/ s! S$ s8 h: A
$ z( @' T6 k* m4 T假设所有符合条件的有 5 笔+ a4 G9 e! B! ]$ o
有时候回传 1 笔,有时回传 3 笔,是不固定的5 v0 J% }7 o$ ~5 @4 Q
回头查语法定义
6 V9 f6 h$ M5 s9 [0 @5 V( u2 }3 Zwith
% s- C# y5 s' H% U$ ?1 J( i8 fagentset with [reporter]
# ` g4 I- n7 F9 A# P( R2 ]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.
% W! F% s- q; G5 W它只说回传 agents satisfying the given condition+ t* W! z4 G8 k& W/ ^7 N8 P
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + D o; }& _3 u: C0 e) `. t3 |. `: }
* Z4 X7 s0 }- e; W8 n
想确定一下/ e% c* E" o( S. e+ z3 s$ h4 _
谢谢!
) Y8 j2 [6 e. C! y |
|