Range extraction: Difference between revisions

(→‎{{header|Go}}: language change. built in error type.)
Line 1,140:
 
=={{header|PL/I}}==
{{incorrect|PL/I|Ranges must cover >2 integers.}}
<lang PL/I>
/* Modified 19 November 2011 to meet new requirement that there be */
range_extraction:
/* at least 3 items in a run. */
range_extraction: /* 17 August 2010 */
procedure options (main);
declare (c, d) character (1);
declare (old, new, initial) fixed binary (31);
declare in file;
declare out file output;
open file (out) output title ('/out,type(text),recsize(70)');
 
open file (in) title ('/range2.dat,type(text),recsize(80)' );
c = ' ';
open file (out) output title ('/range2.out,type(text),recsize(70)');
get list (old);
 
c = ' '; d = ',';
get file (in) list (old);
do forever;
initial = old;
on endfile (sysinin) begin;
put file (out) edit (c, trim(old)) (a);
stop;
end;
get file (in) list (new);
put edit (c) (a);
if new = old+1 then
do; /* we have a run. */
on endfile (sysinin) begin;
putif fileold (out)> editinitial+1 (c,then trim(initial),d = '-', trim(old) ) (a);
put file (out) edit (c, trim(initial), d, trim(old) ) (a);
stop;
end;
do while (new = old+1);
old = new;
get file (in) list (new);
end;
/* At this point, old holds the last in a run; */
/* initial holds the first in a run. */
put/* fileif (out)there editare (c,only trim(initial)two members in a run, don'-',t trim(old)use )the (a);*/
/* range notation. */
if old > initial+1 then d = '-';
put file (out) edit (c, trim(initial), d, trim(old) ) (a);
old = new;
end;
Line 1,179 ⟶ 1,186:
old = new;
end;
c, d = ',';
end;
end range_extraction;
</lang>
OUTPUT 17/8/2010:
<lang>
0-2,4,6-8,11-12,14-25,27-33,35-39
</lang>
OUTPUT 19/11/2011:
<lang>
0-2,4,6-8,11,12,14-25,27-33,35-39
</lang>
 
Anonymous user