|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序5 v$ r/ R, b( d( w! d7 y% H
其中有一段如下
8 w" e; X* @: ]) U1 V' @2 ~( ^ask turtles with [ infected? = true ]
* S6 ]$ [3 u# N3 A* b我原本以为这句会回传『所有』infected? = true 的 turtle
- ]7 F9 m! ?2 |( z6 k0 f+ E但看结果似乎不是这样。
) f2 y' Q v9 V+ {( F7 Q4 _% k; |1 A
; s1 I2 N+ e Z4 Z, J5 t假设所有符合条件的有 5 笔
& }5 w b- J# }& g2 } X( J5 E有时候回传 1 笔,有时回传 3 笔,是不固定的% L+ O1 I/ f9 T3 A' E+ x
回头查语法定义
) x/ P, [) `1 K& y, s3 N- ?with ; {# V9 \9 I# Q6 A
agentset with [reporter]- V/ w4 G8 H2 s* o9 G2 x0 a7 R
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.9 q5 P0 Z. _4 L6 y8 O+ @9 h
它只说回传 agents satisfying the given condition( N& o* C' N7 h$ z. y* y9 m
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % [! @! d, b0 M! `9 @. V
$ r. ]' I7 W+ s7 R3 K& K
想确定一下
& y. X/ i8 \* Y. E. R" V谢谢!
/ k" v# }8 X) L8 j' Q+ A7 ~4 J |
|