|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; `! }& T, T7 }5 p# S3 k其中有一段如下
' h4 k u$ w9 _5 s/ e6 \ask turtles with [ infected? = true ]
/ w% b7 v' w0 n7 [, Q我原本以为这句会回传『所有』infected? = true 的 turtle: Z3 ~' M; x3 g' W. E
但看结果似乎不是这样。
; E" B2 X9 X# a- V/ n1 @# F/ E- r
8 ^0 c: }; m$ h5 A! J假设所有符合条件的有 5 笔8 ^: O# f& P H- k$ _# F- q2 Z4 F
有时候回传 1 笔,有时回传 3 笔,是不固定的: O9 d/ |2 s* j0 v
回头查语法定义- U0 j! J. |+ e: d5 y
with / h$ j% @/ x9 m7 T
agentset with [reporter]
0 j9 m. ]* {' N# ^' F' ?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.
- n! V- g- V0 u# U它只说回传 agents satisfying the given condition) H: J/ f" C& L1 z+ C N
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ ^+ m9 f5 `- |% f( U( m0 p8 X# t. c& k
想确定一下0 n' q0 K, O; K- E2 m) ?
谢谢! W- L- p+ J) M* s9 h. g
|
|