Anadromes: Difference between revisions

→‎{{header|ALGOL 68}}: Minor tweak and use on logical file end to detect EoF on stand in
(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, stopping when a word = ZZZ is found (which is the last word in words.txt).<br>
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 NOT at eof
DO
STRING word;
read( ( word, newline ) );
NOT at eof := word = "ZZZ";
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
END</syntaxhighlight>
{{out}}
<pre>
3,031

edits