|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ o7 G2 ^4 e+ x3 ~8 a- {
其中有一段如下
N5 x( \6 f1 ?/ e7 c7 E5 Zask turtles with [ infected? = true ] & y# z; g% k6 `! h
我原本以为这句会回传『所有』infected? = true 的 turtle- W% B: e: n6 j. U) `8 p
但看结果似乎不是这样。
/ \, x/ q! P* g6 ^3 d5 ?+ L! Y# c# s8 \! o
假设所有符合条件的有 5 笔" p' c: o- h' V1 \: @& U
有时候回传 1 笔,有时回传 3 笔,是不固定的5 u) m7 }* O5 M# g. a. b' g+ o+ i
回头查语法定义+ }' m1 I& q3 W2 a
with
% C8 o1 P5 y6 H! D& {* Z( hagentset with [reporter]
& A9 R6 b; `/ O/ aTakes 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.# |) x8 C; a* M8 f- W* q) k5 t8 f
它只说回传 agents satisfying the given condition" r$ U8 M+ h/ |' E! _" B
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - o4 D# P+ q" n5 f' Q2 w+ z
+ D+ |" j8 J$ f; e: c3 V1 d; S想确定一下
2 a- H* l$ x+ Y! h0 j; Q* [谢谢!; [7 E4 g9 I& T& J9 m/ r% `3 I
|
|