loop有吧. D% ?7 W) `; a; ]+ n W
loop 0 U2 O; s$ u m c2 C jloop [ commands ]+ v- G- p$ Z6 w& d1 q4 }9 g1 |3 m
Runs the list of commands forever, or until the current procedure exits through use of the stop# R# |$ }" i0 u& A3 `' S
command or the report command.1 Q$ C% n _9 B# K& N
Note: In most circumstances, you should use a forever button in order to repeat something forever. 4 O. } P. [# D# N6 d' n3 rThe advantage of using a forever button is that the user can click the button to stop the loop + H) Y! q8 c9 V8 M& m3 U4 h0 K7 [' z% k% b, {- `; ^+ a
(version 3.1.3); _. k+ c R/ `: `
不过好像不大推荐
globals[p ]$ G' o* f8 u" m, f
to setup- M& L/ T, p9 T: y) n& a
set p 19 [6 B3 U( e! [( r# d4 V
set p p + 1 8 B; w" Y1 l, e9 G* N/ @ show p : P, T* A' f4 n. M end! w* S4 M4 g3 Y# |8 _
我想表达的是让这个循环一直下去,直到p=100时才停止,logo语言该怎么写呢?除了repeat,可否用其它原语表示。5 ?, O, i9 U. D4 l: f
globals[p ml ] % L' f# A7 i! S i0 C- |8 @+ hto setup# F2 p" N5 O2 i. Q# K
set ml n-values 200 [ifelse-value (random-float 1 < 0.3 ) [0] [1] ]! D) l7 {$ p* R: H0 o( v8 N& r+ {
set ml filter [ ? = 1] ml0 A& V. f. E M* t
set p 1 2 }# X/ J( K3 v& W. j& }. ]repeat length ml [ set p p + 1]" }6 n' n' j J* X! s3 ?
if p > 100[stop] ) v- Y4 D. M. h% ]; n/ b9 {2 x5 ushow p ) a# N1 J: m4 x' x7 A
end# g" H0 f V. p+ K+ I: ?3 }
6 i) }, R1 O% \
像这种简单的迭代加和还可以,但如果牵涉到多变量的迭代加和,不知道该怎么表达。还有,如果想取出运行中每个阶段的值而不仅仅是终值,该怎么取呢?& \6 w( T& a9 A6 ?: I+ N