|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 m; M6 z5 R6 S其中有一段如下
a. |" P. \% j7 E- g6 m+ x% Zask turtles with [ infected? = true ] 4 c2 R4 N! ^, d4 d
我原本以为这句会回传『所有』infected? = true 的 turtle
5 h: T8 G4 E" F- E# r7 V! r n但看结果似乎不是这样。0 C& r0 Z: }3 y4 Q. ]1 R) a
6 C6 L) S: g e" ~# p3 D
假设所有符合条件的有 5 笔
9 J2 \' g& ~& Y# Z2 C7 i* N: t有时候回传 1 笔,有时回传 3 笔,是不固定的
0 n$ H7 X+ x' {6 K. L, I' R& g0 `回头查语法定义
3 u. q# e" m0 j5 x3 j7 ` ^with . Z. O" R7 B' m1 v3 c: G1 b% K# U
agentset with [reporter]
4 G$ G: x9 G/ n: z' 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.3 W! P7 i: `3 e4 [" ?
它只说回传 agents satisfying the given condition
9 G( P9 b5 T% Z. ^: V$ T8 e+ n2 D是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 {8 [" N2 C7 B3 O3 \7 C& B
! S: @, l+ c- S I想确定一下; c6 [/ Z2 Z1 c7 G5 w* J
谢谢!
$ d: j4 h; p1 p0 D& t |
|