|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 V/ g4 s, |. N/ D& h4 C
其中有一段如下
2 ~: M& }1 W( M7 R7 B; M+ ^ask turtles with [ infected? = true ]
- ]& b6 y1 X8 x4 T5 U我原本以为这句会回传『所有』infected? = true 的 turtle
) {1 ~0 y7 j5 E5 k但看结果似乎不是这样。
. g/ K$ ^& T/ p5 \; p
7 K3 Z1 M+ \4 x1 A% y& x# Q假设所有符合条件的有 5 笔
- Q( k3 `, d. o8 x+ F7 k& C有时候回传 1 笔,有时回传 3 笔,是不固定的
9 W2 k F9 s! z5 {' t6 P回头查语法定义9 Z/ b+ J1 Z# u' S
with
# A k: T! ^7 f# {agentset with [reporter]) b7 }- s! j! z+ X3 c7 N; W
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.
6 x1 s: \" l! [4 k3 g它只说回传 agents satisfying the given condition
# m- ?: I7 f8 ^0 A3 l, z是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 K& A& {# G1 K- c
0 S1 P( E( J( s- ?想确定一下- U- \7 D9 U$ d9 {- m" _. V6 T5 m. K( x8 Y
谢谢!
8 Y: `5 u# Y, m* v, c8 K |
|