|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( f" E% G! o- Z' j其中有一段如下
$ U; A8 X# J% p8 s6 r- fask turtles with [ infected? = true ]
0 D1 j1 j) g9 x" @7 j我原本以为这句会回传『所有』infected? = true 的 turtle) w7 |% D5 _$ j' B4 J0 i' F
但看结果似乎不是这样。
: V, m9 r. ]. x/ ~, A+ G( \$ g5 Q. y; }0 Q
假设所有符合条件的有 5 笔6 G- ]7 `# ~# t. h$ W! [) W
有时候回传 1 笔,有时回传 3 笔,是不固定的1 t- z1 E; @2 m. A
回头查语法定义
! ?9 f2 [- J( n0 P; X" c! q. ?with 2 I1 t( N# S$ z* P' b' A7 W! Q7 M' J$ o
agentset with [reporter]
( O+ C1 z) Y) X2 STakes 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.
T3 U' O2 G' ?4 b% x它只说回传 agents satisfying the given condition
* e! W' p' Q4 W2 G* P, H _是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, }( G9 S. F! Z# y) |! X& l
0 B; c$ H1 E4 U; l( g. O+ G; i, d想确定一下8 s2 d5 F2 x1 T
谢谢!
( v- K3 S; Q1 h1 |0 b$ ` |
|