|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% p, m# H5 L. ^) Q/ r4 V4 T其中有一段如下
8 m, O; k! j; I8 v1 D" ?ask turtles with [ infected? = true ]
* c3 i6 K9 m3 T1 ^' Q. y我原本以为这句会回传『所有』infected? = true 的 turtle
4 \8 f4 x7 i5 j. G& X但看结果似乎不是这样。
* A5 L- p, f7 d9 _- n3 y* d0 A, h6 p9 h% z8 r' {
假设所有符合条件的有 5 笔) Q) {; c% a* r7 _4 i" W
有时候回传 1 笔,有时回传 3 笔,是不固定的' |, T- Y* g8 u. a j5 _
回头查语法定义
5 j3 L. h* @ o1 kwith
7 k4 N7 S& a, Gagentset with [reporter]
! L) ?6 [) d0 U6 y. z4 i$ GTakes 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.% O2 i; L8 ^$ r, @: l( g4 I
它只说回传 agents satisfying the given condition
7 v" B& X- L2 e2 f+ w3 |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; V: v _: b- l+ Y4 {. v( P0 S
3 q3 N% x7 G. y8 s B) A( G# k' b想确定一下
: ~, `/ |. K: l# i* P( O谢谢!2 v: S0 s- k/ s, z/ x6 Q0 J
|
|