|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
6 L; a2 q" K7 ~其中有一段如下& S5 w7 R# A7 N$ D8 o
ask turtles with [ infected? = true ]
* m' _/ P( S, u4 Z) V8 F8 m+ {我原本以为这句会回传『所有』infected? = true 的 turtle
, k4 u1 ` t5 ]但看结果似乎不是这样。
, L* P' m3 \) r" N
, L9 ~7 E& @0 w' n+ v' J假设所有符合条件的有 5 笔5 I# h# {, ^( P
有时候回传 1 笔,有时回传 3 笔,是不固定的
4 ]( u( F E) T: [回头查语法定义
/ _' v; [0 w& ^with
4 a) [0 [! \6 _, T% Xagentset with [reporter]8 j6 V8 V- K& z2 F s
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.
# P: @( u. T S" U它只说回传 agents satisfying the given condition
) }6 V5 g! S# ]- t/ S! i是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; v& W$ k- ]8 `2 P+ `/ J2 O
, ]& i5 ]7 [5 q6 Q4 L+ k2 n+ h想确定一下
! K2 s: {9 ?1 y- D谢谢!
# l1 G- B+ n$ C |
|