|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ x6 d R: A7 u ^# Y. f其中有一段如下
7 T7 z; Y7 x7 u4 T+ H! Task turtles with [ infected? = true ] + U9 Q$ _8 b4 r
我原本以为这句会回传『所有』infected? = true 的 turtle
" A7 m: N4 O$ T8 M但看结果似乎不是这样。
! O2 t% F% L8 v, \! W2 O' H# a/ X4 x+ \8 D7 q
假设所有符合条件的有 5 笔
6 X: C E2 U1 K) L有时候回传 1 笔,有时回传 3 笔,是不固定的+ K, K) z, \7 J9 D5 h
回头查语法定义
% b( c& f ~3 vwith
" p+ R0 Y9 x, R- L3 Cagentset with [reporter]
; K5 s& |; K: n4 P' [5 q; c# nTakes 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.
. D& F2 K' Y# @它只说回传 agents satisfying the given condition
8 B/ o" c5 S5 w/ U( h6 }* |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
4 b2 D( b% ?. P* h7 i1 r8 J4 Y" |5 F" m* Y
想确定一下
+ l V7 X: R7 `5 H5 H2 D7 U谢谢!" o$ Q4 Y* n8 l% Y
|
|