|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ N& u" S% L8 U7 T* E0 E7 I/ S其中有一段如下9 F& T3 V: l: T6 x; F; k" O
ask turtles with [ infected? = true ] / N% t& F. a8 @
我原本以为这句会回传『所有』infected? = true 的 turtle$ ]$ q! e* A3 K, K
但看结果似乎不是这样。
- {6 s! k" B% v' f# S) O" b, G1 [' `: Y5 t
假设所有符合条件的有 5 笔( Q6 F6 j- H9 L3 \0 E6 |: n R3 z
有时候回传 1 笔,有时回传 3 笔,是不固定的3 b5 B$ r( V6 ^8 V2 T
回头查语法定义
% `8 N8 x' t0 t) w- cwith
+ M. l- t0 d! X5 }) Dagentset with [reporter]( t& |+ J* R A% J2 P) z- 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.
2 Z# [. m4 t! ]8 Z$ B. t它只说回传 agents satisfying the given condition
i! r8 p4 n* `) K3 Y6 R& [& z4 I是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 Y7 h4 r2 }' f+ c6 H
) o6 r- N0 G2 e' b- L+ t
想确定一下, A, f" Z4 z. M" U$ p5 C$ ?; v
谢谢!
p+ x& o( ~* [% z6 M |
|