Anonymous user
Longest string challenge: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, used a template for the output.
(Added Julia language) |
m (→{{header|REXX}}: added/changed comments and whitespace, used a template for the output.) |
||
Line 1,737:
=={{header|REXX}}==
In the REXX language, ''everything'' is a string (characters).
<br>A stemmed array (y.1 y.2 y.3 ∙∙∙) is nothing more than three disjointed REXX variables.
===read file until E-O-F===
<lang rexx>/*REXX
!.=
fileID= 'LONGEST1.TXT'
do while min( lines(fileID), 1) /*form to bypass using conditional test*/
_=linein(fileID); w=length(_) /*obtain a line; obtain the width(len).*/
!.w=!.w || '0a'x || _ /*build a stemmed array element. */▼
do j=m for m /*handle the case of no input. */
▲ say 'input =' _ /*display the input to terminal. */
▲ !.w=!.w || '0a'x || _ /*build a stemmed array element. */
exit /*stick a fork in it, we're all done. */
end /*j*/</lang>
{{out|output|text= when using the default input:}}
▲ do j=m for m /*handle the case of no input. */
<pre>
▲ say center(' longest record(s): ',79,'═')
▲ say substr(!.m,2)
▲ exit /*stick a fork in it, we're done.*/
▲ end /*j*/</lang>
input = a
input = bb
Line 1,774:
===read file until not ready===
<lang rexx>/*REXX
!.=
fileID= 'LONGEST2.TXT'
signal on
m=0 /*the maximum width
do forever;
say 'input =' _ /*display
!.w=!.w || '
m=max(m, w) /*find the maximum width so far. */
end /*forever*/
say center(' longest record(s): ', 79, '═')
say substr(!.m, 2)
say center(' list end ' , 79, '═')
exit /*stick a fork in it, we're all done. */
end /*j*/</lang>
{{out|output|text= when using the default input:}}
<pre>
input = -3
input = -two
Line 1,818:
══════════════════════════════════ list end ═══════════════════════════════════
</pre>
===Dual code (works on TSO and PC)===
<lang rexx>/* REXX ***************************************************************
|