|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ L' `% T3 Q$ `' J! C% Z其中有一段如下' c$ I, d& |; H; m; L' D3 v1 j1 p
ask turtles with [ infected? = true ] % g* T) Z- U. p# Q5 `8 }# v
我原本以为这句会回传『所有』infected? = true 的 turtle
6 f+ r, [% u$ D* H但看结果似乎不是这样。
: ?1 M: u1 o" @ X* D" i3 h. Q$ f' F% X& V. ^# p- |1 U9 S( A
假设所有符合条件的有 5 笔5 z2 D. M7 ?, l" K; u3 z& B
有时候回传 1 笔,有时回传 3 笔,是不固定的
! C. c7 f, ]: j6 C! ` g回头查语法定义
4 E& g$ n) j5 t4 ~; Z5 x8 Wwith
4 c: Q" u5 i, Wagentset with [reporter]$ M, [% f( F( {% L, a, ]
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., x# X% Z5 [1 y# V; V7 Y/ I) k+ d# H
它只说回传 agents satisfying the given condition
$ V0 M, x9 S# P- n G2 p) ~: M N是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & U x+ J9 A: _& o
9 R1 B% L' _0 B
想确定一下
' p s g+ |% j8 I谢谢!3 w6 T7 N0 O* K0 B
|
|