|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. {% G3 H. B( ^8 h( d! y) G; t
其中有一段如下
8 p! { @4 Y1 K- |$ |9 f9 task turtles with [ infected? = true ] 0 B1 ] g: f r. k; L" _0 c- H
我原本以为这句会回传『所有』infected? = true 的 turtle
0 t' @- b6 Y8 k" s9 `6 u: ^* H但看结果似乎不是这样。
. U* f' y9 J5 `1 [9 }+ q" b! Z; t/ J9 {, W- R8 Q9 m* Z0 c, Y
假设所有符合条件的有 5 笔
5 J# K3 }/ e5 n有时候回传 1 笔,有时回传 3 笔,是不固定的7 [# w% w( r, G- ~+ @8 h9 p
回头查语法定义
+ {1 T- S( ?, B: Q1 hwith B' D7 p7 ^0 V) F0 f6 v
agentset with [reporter]* w3 [( C- s7 j$ ]+ m) j
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.+ j: {$ @. D$ B# G0 d! @/ H
它只说回传 agents satisfying the given condition
, ~. o, M9 P$ B; [9 N是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% {4 {' }- {" U4 l+ I& x) T: c( n/ X3 ~6 G& N
想确定一下
4 k+ K, L2 U8 @) R6 I M; L谢谢!. M/ u f' [% S5 ]$ _4 c
|
|