|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" m7 I" p8 _" [9 o+ c7 o) `$ [
其中有一段如下
Q# m7 c+ E" R* Mask turtles with [ infected? = true ] ' g% d4 b4 k+ ^! \+ m
我原本以为这句会回传『所有』infected? = true 的 turtle, {6 S& |, M8 h; t
但看结果似乎不是这样。
, C B8 P' Q6 I- y8 I8 M6 O
1 S7 o7 I( W7 j! e2 J! K假设所有符合条件的有 5 笔; p$ [% Q; s8 e2 m- g
有时候回传 1 笔,有时回传 3 笔,是不固定的6 x# T- X1 n/ l7 |1 I: H2 ?1 B: S' O
回头查语法定义
3 k1 X6 J: { x; G) Dwith % {" Y$ Y u9 _7 I5 s, H
agentset with [reporter]8 p/ k; a. l4 [. X, i) ~, z
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 \. ^" K& D4 M6 n它只说回传 agents satisfying the given condition( n3 Q6 {+ S" R
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ Y g' l6 P# E6 _. s% ^; y; J9 A: _. q: ^7 v! x1 w: ~
想确定一下$ H; H% L5 U+ v7 X. i4 C6 z
谢谢!( R( q# C3 p6 M! E7 e1 _
|
|