|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& l3 x! K2 S: u0 O其中有一段如下
5 i3 @' c* j/ R6 cask turtles with [ infected? = true ] 2 T' f/ G9 \) j% n
我原本以为这句会回传『所有』infected? = true 的 turtle
4 `3 B( H: U( B6 j但看结果似乎不是这样。
0 ^3 g7 `$ B+ E, a" C# m# P K" Y2 S% B: J% h5 [; C7 H
假设所有符合条件的有 5 笔
7 M. L6 b( T7 y ?* ?) U有时候回传 1 笔,有时回传 3 笔,是不固定的
8 G) M% ]0 k1 j; p+ D! x9 K8 J- y回头查语法定义# Q9 H8 l _; T: j7 I
with 6 o7 ~0 A8 M/ @3 M4 [+ J
agentset with [reporter]% H( d5 O0 x9 f$ j" M5 a
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.7 e2 J8 Y! V% w; p2 ~ e
它只说回传 agents satisfying the given condition
( `9 Q; |& E5 i: n. x+ f( P是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 v, _4 W& M* b/ I, ?: t% L
5 S+ N8 h* z" D6 u
想确定一下6 b% [: m- i2 r# m/ R& P, U0 e
谢谢!, X1 i# A6 C( n
|
|