Stream merge: Difference between revisions
Content added Content deleted
m (added highlighting to the task's preamble.) |
m (→version 2: changed the wording of the comment in the output section, simplified the RDR subroutine.) |
||
Line 453: | Line 453: | ||
do forever; y=$; #=0 /*find the lowest value for N values.*/ |
do forever; y=$; #=0 /*find the lowest value for N values.*/ |
||
do k=1 for n-1 /*traipse through the stemmed @ array.*/ |
do k=1 for n-1 /*traipse through the stemmed @ array.*/ |
||
if @.k==$ then |
if @.k==$ then call rdr k /*Not defined? Then read a file record*/ |
||
if @.k<<y then do; y=@.k; #=k; end /*Lowest so far? Then mark this as min*/ |
if @.k<<y then do; y=@.k; #=k; end /*Lowest so far? Then mark this as min*/ |
||
end /*k*/ |
end /*k*/ |
||
if #==0 then exit /*stick a fork in it, we're all done. */ |
if #==0 then exit /*stick a fork in it, we're all done. */ |
||
call lineout 'ALL.TXT', @.#; say @.# /*output |
call lineout 'ALL.TXT', @.#; say @.# /*output value to a file; also display.*/ |
||
call rdr # /*repopulate this file's input value. */ |
call rdr # /*repopulate this file's input value. */ |
||
end /*until*/ |
end /*until*/ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
rdr: parse arg z; @.z=$; |
rdr: parse arg z; @.z=$; f=z'.TXT'; if lines(f)\==0 then @.z=linein(f); return</lang> |
||
'''output''' is the same as the 1<sup>st</sup> REXX version when using |
'''output''' is the same as the 1<sup>st</sup> REXX version when using identical input files). <br><br> |
||
== {{header|UNIX Shell}} == |
== {{header|UNIX Shell}} == |