|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( g/ P& K2 a9 n" f- \其中有一段如下
& P$ K# ^* z b* w" Hask turtles with [ infected? = true ] m8 }; d7 B! `! J* B5 B
我原本以为这句会回传『所有』infected? = true 的 turtle" z6 N- \% E+ z, G) d
但看结果似乎不是这样。, O% @7 t- A" Q$ n0 `' d+ j8 H
3 [, h/ \. }0 [+ y2 D4 Z# P H j4 E5 F
假设所有符合条件的有 5 笔
/ F5 S! M( y, |! N5 u" q有时候回传 1 笔,有时回传 3 笔,是不固定的
7 P& U4 G, ]$ R3 t7 h7 X回头查语法定义
4 q; u0 T% r; d3 k6 k" ~. ~- G2 y; ~with - Q) h2 T) \7 n }& B" l v
agentset with [reporter]
2 q1 ~9 i# i" E$ F$ S' eTakes 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.4 i* O- H4 q. Z. f1 s
它只说回传 agents satisfying the given condition' `* W2 x6 k* S+ q/ ], n
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 j* T+ d9 b( C5 Z/ h* z% Q1 h& x
: {. T2 G6 f- t* l' u6 L
想确定一下5 `) [5 Q- F1 r) z m
谢谢!
5 t- R+ b% E- ^5 Y' N4 S |
|