|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 ? _% ]2 x) P% ^2 M% Q
其中有一段如下
$ O- ?; ]. t' J( _) nask turtles with [ infected? = true ]
# H- O. ?0 e1 G; u, s# _. J) p我原本以为这句会回传『所有』infected? = true 的 turtle
+ B2 i; z/ e3 u b' F/ U8 N但看结果似乎不是这样。" y" t2 k6 e7 N4 {1 u
4 P3 `) R+ y3 V, V2 |& W/ t& u假设所有符合条件的有 5 笔! W/ x% J! X8 i* Z5 V/ M
有时候回传 1 笔,有时回传 3 笔,是不固定的
3 x* R! z& t: D; W# i回头查语法定义9 |7 Z2 a1 B7 A# p( |% c
with
! L7 x' _& L* T4 l' @- wagentset with [reporter]
$ n5 `3 o4 t9 V3 I- Q+ YTakes 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.8 z) ]1 n9 d4 G0 |3 _/ j8 I* z
它只说回传 agents satisfying the given condition; T; T* {, ?* }# t! e
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " I" H3 R: B" F4 Y' S
+ o6 U& E4 o9 ? C7 H2 W1 l
想确定一下
. I+ h! i( c6 |7 X( \谢谢!
! Y& W4 d# S/ h f4 w$ E |
|