Debian Codegraph @

src/test/01-Basic/159-repeat.ck

raw
1 // a 'repeat' loop repeats for a fixed number of repetitions
2
3 // our counter
4 0 => int x;
5
6 // repeat a fixed number of times
7 repeat( 4 )
8 {
9 x++;
10 }
11
12 // repeat x number of times (or what the value of x is when we first
13 // reach this loop...e.g., should be 4 in this instance)
14 repeat( x )
15 {
16 // the repeat value 'x' is evaluated only once at the beginning
17 // of the loop; even if 'x' is subsequently changed, it will not
18 // alter the number of repetitions of the loop
19 x++;
20 }
21
22 // verify where the counter ended up
23 if( x == 8 ) <<< "success" >>>;