Longest string challenge: Difference between revisions

Content added Content deleted
m (→‎read file until not ready: elided the need to initialize the variable named M.)
m (→‎read file until not ready: changed some comments and whitespace.)
Line 1,750: Line 1,750:
signal on notReady /*when E-O-F is reached, jump/branch. */
signal on notReady /*when E-O-F is reached, jump/branch. */


do rec=1; _=linein(iFID); w=length(_) /*read a line from the input file. */
do r=1; _=linein(iFID); w=length(_) /*read a line from the input file. */
do y=rec to 1; m=w; w=0; $=y || _; end /*first initialization.*/
do y=r to 1; m=w; $=y || _; iterate r; end /*first initialization.*/
do n=m for 1; end /*for smaller records. */
do n=m for 1; end /*for smaller records. */
do z=n to w for 1; $=; end /*found longest record.*/
do z=n to w for 1; $=; end /*found longest record.*/
do x=m to w for 1; $=$'a0d'x || _; end /*append record to $. */
do x=m to w for 1; $=$'a0d'x || _; end /*append record to $. */
m=max(m, w) /*M: is the maximum length record. */
m=max(m, w) /*M: is the maximum length record. */
end /*forever*/
end /*r*/


notReady: do j=m for m /*handle the case of no input. */
notReady: do j=m for m /*handle the case of no input. */