raz / conform / run / Continue.raz

49 lines · 1.2 KiB · raw · history · last change 264716cb

1(* continue ends the round of the innermost loop: a while tests its
2 condition again, a repeat its until, a for steps or ends; and the
3 statements deferred in the round run on the way (report 2026-10.31,
4 sections 7.2 and 7.7). *)
5module Continue;
6import Out;
7
8proc main*;
9var i, j, n: INT; t: []const U8;
10begin
11 for i := 1 to 10 do
12 if i mod 3 = 0 then continue; end; (* a lone continue *)
13 Out.int(i); Out.str(" ");
14 end;
15 Out.ln;
16 for i := 10 to 1 by -2 do
17 if i = 6 then Out.str("six "); continue; end;
18 Out.int(i); Out.str(" ");
19 end;
20 Out.ln;
21 t := "a-b--c";
22 i := 0;
23 while i < LEN(t) do
24 n := i;
25 i := i + 1; (* the step first *)
26 if t[n] = '-' then continue; end;
27 Out.str(t[n..i]);
28 end;
29 Out.ln;
30 i := 0;
31 repeat
32 INC(i);
33 defer Out.str("|");
34 if i = 2 then continue; end;
35 Out.int(i);
36 until i >= 4;
37 Out.ln;
38 for i := 1 to 3 do (* the innermost loop's round *)
39 for j := 1 to 3 do
40 if j = 2 then continue; end;
41 Out.int(10 * i + j); Out.str(" ");
42 end;
43 if i = 2 then continue; end;
44 Out.str("; ");
45 end;
46 Out.ln;
47end;
48
49end Continue.