|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
# A! l6 d" \1 I F0 ~+ P- _其中有一段如下
- L5 T, x* _+ D r k: e0 f% oask turtles with [ infected? = true ] 7 q' [" L) w+ l. K9 l' n5 u
我原本以为这句会回传『所有』infected? = true 的 turtle
+ b+ U1 X: h: j8 [# s( `6 N但看结果似乎不是这样。: c v7 I& F3 V
8 i. W+ h9 k. A# I. r9 Z$ B* F
假设所有符合条件的有 5 笔
! m% V) r2 w6 [& F) Y( `/ B; I有时候回传 1 笔,有时回传 3 笔,是不固定的3 H6 e0 |! \: o/ B) H4 r, y' k8 i
回头查语法定义$ Y1 H7 g" I1 {$ Q! E @; v& r
with 6 w+ |- q- k. j6 N9 A2 y5 |% B+ G& k
agentset with [reporter]& @3 E8 r' K9 e" W0 l* 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.
# M4 j' G) k; J它只说回传 agents satisfying the given condition0 Z9 l; d; _8 S% n" F4 s
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ ~6 [7 v1 \ f8 h8 o/ ^' f
6 B5 }; y4 m9 a# T想确定一下; G# e1 f6 n1 i( X* F! ^% H) E# b4 x
谢谢!- [$ O7 M" {( ^; n6 L
|
|