Range expansion: Difference between revisions
Rewrote XPL0 example.
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(Rewrote XPL0 example.) |
||
Line 4,533:
=={{header|XPL0}}==
See Range Extraction for explanations.
<syntaxhighlight lang "XPL0">proc Expand(Range);
char
int
[Text(8, Range);
other \EOF\ [IntOut(0, Lo); quit];
[Str:= "-6,-3--1,3-5,7-11,14,15,17-20";▼
▲loop [N0:= GetNum;
▲ IntOut(0,N0);
▲ case Char of
▲ ^,: [GetCh; ChOut(0,^,)];
▲ ^-: [GetCh;
▲ N1:= GetNum;
▲ for I:= N0+1 to N1 do \expand range
▲ [ChOut(0,^,); IntOut(0,I)];
▲ if Char=^, then [GetCh; ChOut(0,^,)] else quit]
];
];
]</syntaxhighlight>▼
{{out}}
<pre>
-6, -3, -2, -1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20</pre>
=={{header|Yabasic}}==
|