Anonymous user
Stream merge: Difference between revisions
m
→version 2: elided the use of a dummy variable, added/changed comments and whitespace, utilized the number of files without fudging, used a template for OUTPUT, added verbiage to the REXX section header.
(Added Sidef) |
m (→version 2: elided the use of a dummy variable, added/changed comments and whitespace, utilized the number of files without fudging, used a template for OUTPUT, added verbiage to the REXX section header.) |
||
Line 1,266:
===version 2===
This REXX version reads (in numerical order) ''any'' number of input files in the form of: <big> nnn.TXT </big> and
<br>and stops reading subsequent ''new'' input files when it encounters
The input files would/should be named: '''1.TXT 2.TXT 3.TXT 4.TXT ···'''
No ''heap'' is needed to keep track of which record was written, nor needs replenishing from its input file.
<lang rexx>/*REXX pgm reads sorted files (1.TXT, 2.TXT, ···), and writes sorted data ───► ALL.TXT */
n=n-1
do forever; y=@.;
do k=1
if
end
if #==0 then exit /*stick a fork in it, we're all done. */
call lineout 'ALL.TXT', @.#; say @.# /*
call rdr # /*
end /*forever*/ /*keep reading/merging until exhausted.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
rdr: parse arg z; @.z=
=={{header|Ruby}}==
|