|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% s6 S+ ]1 G" O# x1 M其中有一段如下
" ]5 m- R$ C5 Z3 i+ B K3 V) h& Pask turtles with [ infected? = true ]
5 `+ k8 k3 {, h5 ^% `我原本以为这句会回传『所有』infected? = true 的 turtle j1 F7 a. ?( W9 X6 _4 E
但看结果似乎不是这样。
$ S* b3 b# S0 O7 q- Q9 N% G* X7 L/ M: X9 S5 d0 [# @: U
假设所有符合条件的有 5 笔( y/ X% d1 f. E
有时候回传 1 笔,有时回传 3 笔,是不固定的' t& E/ \* o U5 ^- V% S f5 p
回头查语法定义& {/ a- E5 D5 @, u. O1 _7 L
with
( V! m# Q" k2 K4 @2 e- Uagentset with [reporter]( w" A5 G/ E0 W; o5 u
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 L& c: n8 y它只说回传 agents satisfying the given condition% I# S0 y' ~# j: C- N9 S) G I- {
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & \9 S$ x4 [; h
, |$ o4 j0 V( N' X
想确定一下! E8 r: X M7 p( U5 J
谢谢!
2 Q8 w3 K ~& g t8 Y |
|