Anadromes: Difference between revisions
→{{header|ALGOL 68}}: Minor tweak and use on logical file end to detect EoF on stand in
Not a robot (talk | contribs) (Add SETL) |
(→{{header|ALGOL 68}}: Minor tweak and use on logical file end to detect EoF on stand in) |
||
Line 81:
=={{header|ALGOL 68}}==
Reads the words from standard input
Unfortunately, Algol 68G doesn't like an array of STRINGs with more than 300 000 elements, even though it allows INT arrays to have millions - at least under Windows<br>
(I haven't tried it with Linux).<br>
Line 131:
list[ low ] = item
END # contains # ;
# set the end of file handler for stand in #
on logical file end( stand in, ( REF FILE f )BOOL: at eof := TRUE );
[ 1 : 500 000 ]STRING words;
Line 137 ⟶ 140:
INT max length := 0;
BOOL at eof := FALSE;
WHILE
DO▼
STRING word;
read( ( word, newline ) );
NOT at eof
▲ DO
t count +:= 1;
INT w length := 1 + ( UPB word - LWB word );
Line 175 ⟶ 178:
OD;
print( ( newline, "Found ", whole( a count, 0 ), " anadromes", newline ) )
END
{{out}}
<pre>
|