|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 ?% k, n8 N4 b) m! R+ ^, e其中有一段如下
! H. _6 }" b3 [( X' L) J; ~+ xask turtles with [ infected? = true ]
~/ A% e9 {5 L' Q) ?我原本以为这句会回传『所有』infected? = true 的 turtle
% t i* w: g0 G% b$ w+ d但看结果似乎不是这样。
( q: |: x1 W$ ~; ]6 i4 d, f! p6 Q4 B" c% r" y) @
假设所有符合条件的有 5 笔 D: r a. s' Q5 M! o: z2 b
有时候回传 1 笔,有时回传 3 笔,是不固定的! T0 y" \& p1 Q4 K% L; j+ Z
回头查语法定义$ [/ m$ m/ E/ J
with
7 m7 @7 U0 Y4 _! `4 Xagentset with [reporter], q4 [8 F8 L3 k6 _6 O
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. A& |, E, w% y3 g6 u# R
它只说回传 agents satisfying the given condition
6 c6 N# d ]6 B7 `4 L; n. R+ e是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - k9 Z: x- P' U, E9 O
$ F0 n* A# b4 f( W9 X# [) l; L( E想确定一下
& `* O b- m3 X# e6 p9 L s谢谢!
# @, v s+ Y2 F9 v6 _ |
|