Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Range-extraction/XPL0/range-extraction.xpl0
Normal file
32
Task/Range-extraction/XPL0/range-extraction.xpl0
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
string 0;
|
||||
def End = -1>>1;
|
||||
|
||||
func RangeExtract(List); \Return a string in the range format
|
||||
int List, I, Lo, Hi;
|
||||
char String(0);
|
||||
[I:= 0;
|
||||
loop [Lo:= List(I);
|
||||
while List(I)+1 = List(I+1) do I:= I+1;
|
||||
Hi:= List(I);
|
||||
IntOut(8, Lo);
|
||||
if Hi-Lo >= 2 then
|
||||
[ChOut(8, ^-); IntOut(8, Hi)]
|
||||
else if Hi-Lo = 1 then
|
||||
[ChOut(8, ^,); IntOut(8, Hi)];
|
||||
I:= I+1;
|
||||
if List(I) = End then quit;
|
||||
ChOut(8, ^,);
|
||||
];
|
||||
ChOut(8, 0);
|
||||
I:= 0;
|
||||
loop [String(I):= ChIn(8);
|
||||
if String(I) = 0 then return String;
|
||||
I:= I+1;
|
||||
];
|
||||
];
|
||||
|
||||
Text(0, RangeExtract(
|
||||
[0, 1, 2, 4, 6, 7, 8, 11, 12, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 27, 28, 29, 30, 31, 32, 33, 35, 36,
|
||||
37, 38, 39, End]) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue