|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ f# N( [) Z8 ~4 f9 O4 I" |; h其中有一段如下/ U* {& a4 k( A# W& m2 X2 W
ask turtles with [ infected? = true ] 0 m% g2 {5 t3 W2 o. K$ h9 f1 O
我原本以为这句会回传『所有』infected? = true 的 turtle- N$ i4 M2 ]7 [2 ^
但看结果似乎不是这样。9 t% u( V3 k# K/ s: g9 b
+ r* @2 @( F+ s) I% Y& f) R
假设所有符合条件的有 5 笔
2 T$ l! @- q( [# b0 B& X有时候回传 1 笔,有时回传 3 笔,是不固定的
/ P) N6 H- h7 y% T回头查语法定义: D, F8 z9 \5 v
with
4 q9 L( Z+ t4 q% eagentset with [reporter]9 Z# n" `- e; i+ \1 w+ 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., D4 M( X" z" P' [' W
它只说回传 agents satisfying the given condition
# R$ L4 ~1 O9 ~$ W0 ?2 L是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & ~1 f S. z9 O
y) x1 Q1 {5 d5 \4 B
想确定一下: C7 V6 \2 a% `8 o2 t1 a6 K0 |. ]; A
谢谢!
: }# \$ l$ l' R, g |
|