|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" [* F# j; c0 g# G
其中有一段如下
, j+ h% j* S# x5 Y6 ]" @ask turtles with [ infected? = true ]
# f- T7 h; H7 ~5 j/ X* Q. e我原本以为这句会回传『所有』infected? = true 的 turtle
% C0 m7 d0 u2 f% f% c$ u但看结果似乎不是这样。# y- k! P6 @" D
* G6 h7 i, B2 [; A9 U9 m) J- X( {
假设所有符合条件的有 5 笔+ h ^3 b- m- t$ N$ z- e6 ~
有时候回传 1 笔,有时回传 3 笔,是不固定的 U% @ s$ S0 {, y8 ?4 p, V
回头查语法定义
$ F$ j0 V) U4 \2 k8 d" W1 Q* k9 nwith ' u4 N9 A% g/ |$ [ c9 x5 I
agentset with [reporter]8 |9 s% P+ |( q" e* G( \8 D+ D
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.
3 X" Q' X, x: d ~5 u0 }它只说回传 agents satisfying the given condition: W# o9 [9 Z. J0 s0 K7 V+ D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( @" H! y+ f. U2 [5 P
6 a) m5 n$ s1 G1 M想确定一下
" Q0 G7 ?. Z$ S f谢谢!
9 }# W5 I1 k5 S* |3 i6 S: j |
|