|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ I' W7 \4 T, ]; K/ ~其中有一段如下
% H4 R- h3 w4 Q# Y, ?ask turtles with [ infected? = true ]
# g$ \* Q& m. [/ ~; G# p7 I- ^我原本以为这句会回传『所有』infected? = true 的 turtle
+ |6 K5 \" T* v+ T6 s# e) b但看结果似乎不是这样。5 H! z3 e; A. S. \" c
# k% m+ @) q% U, T; L8 v( E5 L假设所有符合条件的有 5 笔& b+ O0 F5 W4 Q2 |# }: F; Z. u
有时候回传 1 笔,有时回传 3 笔,是不固定的
4 \+ ~1 \8 |/ ~+ Q回头查语法定义2 R A- E& R! E! b ~" k3 B2 Q3 h! q
with # X! O% E8 A! h
agentset with [reporter]) p: M0 R! T! R- Y& l
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 D. L- A0 H. ?$ F; k9 b6 A
它只说回传 agents satisfying the given condition, j1 A4 ]3 y% C, m, G+ z
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# \: g( p% I" N- j2 V" ? x* U5 O( ^/ @/ h2 m
想确定一下
( o) S+ [( L7 {6 c3 Y0 T谢谢!5 C. ` f. ^7 k" _4 A3 s% A
|
|