Largest int from concatenated ints: Difference between revisions

m
→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations, optimized inner DO loop.
m (→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations, optimized inner DO loop.)
Line 1,636:
if _>digits() then numeric digits _ /*use enough decimal digits for maximum*/
/* [↓] examine each number in the list*/
do while z\==''; index=1 index=1 /*keep examining the list until done.*/
big=isOK( word(z, 1) ); LB=length(big) /*assume that first integer is biggest.*/
/* [↓] check the rest of the integers.*/
do k=2 to words(z); #=isOK(word(z,k)) /*obtain an an integer from the list. */
L=max(length(big)LB, length(#) ) /*get the maximum length of the integer*/
if left(#, L, left(#, 1) ) <<= left(big, L, left(big, 1) ) then iterate
big=#; index=k /*we found a new biggie (and the index)*/
end /*k*/ /* [↑] find max concatenated integer. */
Line 1,655:
isOK: parse arg ?; if datatype(?,'W') then return abs(?)/1 /*normalize the integer.*/
say; say '***error*** number ' ? "isn't an integer."; say; exit 13</lang>
'''output''' &nbsp; when using the default (internal) integer lists:
<pre>
998764543431 max for: {1, 34, 3, 98, 9, 76, 45, 4}