|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ u6 g/ [( ^7 I: c% m% w其中有一段如下
; w* f9 ?3 d# aask turtles with [ infected? = true ] 9 Y n4 Q. e( q& R' T |: W: e
我原本以为这句会回传『所有』infected? = true 的 turtle
) S* a% l; v6 b! L但看结果似乎不是这样。$ Y; S9 b+ ]# U; _" S x
% i0 } P$ x' N, D
假设所有符合条件的有 5 笔
/ o2 W4 T1 U# I4 F% [1 W有时候回传 1 笔,有时回传 3 笔,是不固定的
5 X; y; K" T. c+ x回头查语法定义3 V& o' }0 u: o! o
with
; M2 Z& g6 j) F3 `$ tagentset with [reporter]4 O8 c% ~: M9 j. s& g
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.
" y: M$ Y8 z: z6 [7 |" F# }5 o它只说回传 agents satisfying the given condition5 k! {' [' y2 U4 o9 [1 n3 ]' ?
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * E$ K# ~/ k l2 g, x
: s& A( k$ G0 b% H5 T* Q: ?想确定一下: d) R9 [1 D) \
谢谢!0 a7 Y7 p& J4 @6 ]( A% R
|
|