|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 {2 x% ]. r [, M4 |% }! ?
其中有一段如下
1 Q: x* i( F; y1 Mask turtles with [ infected? = true ] + W7 t1 g/ W4 @4 n* N
我原本以为这句会回传『所有』infected? = true 的 turtle
5 w, |' ~9 d" V5 H5 ]% j; Q7 G/ s6 ^8 m但看结果似乎不是这样。; }! P& N1 y2 G; X) p, g9 e
9 x* J7 Z! k7 c
假设所有符合条件的有 5 笔& C* X' ~- X7 r. e4 O M
有时候回传 1 笔,有时回传 3 笔,是不固定的
+ t! A* K8 X2 l3 v8 b回头查语法定义 i" h/ V8 Q2 s3 A+ ^
with
. e- D: W4 ^0 p& e% D' R5 pagentset with [reporter]
* r8 D* ?1 `! s- u# N- [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.. g# o" P, l" I! b. C! A" `
它只说回传 agents satisfying the given condition
/ C! s6 I, B+ \! Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) y$ i0 t3 ?& P5 J# ~
" P7 J. D: ?: _. T
想确定一下
# C# P& \! m6 A2 P) a/ T: I8 _# M* U8 [谢谢!
+ E# M/ P* e2 Q. n! a |
|