|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! g) O8 I2 \& M) C$ c6 @其中有一段如下
- }6 q* ], |, W1 x: e% p0 K ]ask turtles with [ infected? = true ]
2 \( A) }& Z# v0 E, L2 v* L我原本以为这句会回传『所有』infected? = true 的 turtle* @: O( I8 r6 b( @' N' P
但看结果似乎不是这样。5 e: ?: K+ T$ p) |
6 K. }+ b# `8 D; d* _" o& |3 P假设所有符合条件的有 5 笔3 A! n( K$ n6 B3 @' G8 [. F5 W
有时候回传 1 笔,有时回传 3 笔,是不固定的
, W- `9 L, A$ G: ?6 @回头查语法定义6 R( P% l4 H* t! V
with
$ r2 K; k7 ?3 s! a9 eagentset with [reporter]: L$ M8 }9 n6 Y
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.( |0 x2 ?& ^' G, |$ _
它只说回传 agents satisfying the given condition/ K8 Z+ t1 D7 K5 W8 i) ^* Q- K
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 t% N. k Y; A1 \
1 a$ l5 E+ |) k: _1 r' D. d$ X
想确定一下
! a7 ^5 H5 O# P: r* T5 N谢谢!
$ P. t* N/ T& P9 ~7 }* @" b |
|