|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- y& r) N8 `* x4 e4 h" ]
其中有一段如下
1 F& E# B" G( Q- @' W7 |9 Pask turtles with [ infected? = true ] 0 f% [' b% J# p0 ~/ q- `9 ~
我原本以为这句会回传『所有』infected? = true 的 turtle
* Y) R A5 ~2 |5 d0 P但看结果似乎不是这样。! I5 ~5 [* l: F$ j( \% y; l) C
# {7 O, e# S8 \9 I- b1 ] l+ Q8 ?
假设所有符合条件的有 5 笔) \5 G* r$ }2 @3 N0 j; e
有时候回传 1 笔,有时回传 3 笔,是不固定的, y1 e0 Z- m" x$ d/ J- V
回头查语法定义- s4 _3 A2 E% `4 Z* |
with . X$ W2 Q1 P' i4 R) P$ }. Q
agentset with [reporter]9 V8 i" ?& }+ I, h, {
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 N) k7 ?! C; V2 z3 c它只说回传 agents satisfying the given condition- z9 h, O6 [4 x$ J! C* m
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' b5 A& z, ~8 x% S( n
/ K% t3 r7 j; G( Q: n4 F
想确定一下) |! y) ?. q7 O! Z( x
谢谢!
! M! _+ C% F: [- x6 ]7 i! C2 ~ |
|