Find words which contains more than 3 e vowels: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 1,655:
15: telemeter
16: tennessee
</pre>
 
=={{header|XPL0}}==
<lang XPL0>string 0; \Use zero-terminated strings
int I, Ch, Len;
char Word(100); \(longest word in unixdict.txt is 22 chars)
def LF=$0A, CR=$0D, EOF=$1A;
 
func Vowel(Ch); \Return 'true' if character is a vowel, except "e"
int Ch;
case Ch of ^a, ^i, ^o, ^u: return true
other return false;
 
func Es;
\Return 'true' if Word contains more than 3 e's and no other vowels
int Cnt, I;
[Cnt:= 0;
for I:= 0 to Len-1 do
[if Word(I) = ^e then Cnt:= Cnt+1;
if Vowel(Word(I)) then return false;
];
return Cnt > 3;
];
 
[FSet(FOpen("unixdict.txt", 0), ^I); \open dictionary and set it to device 3
OpenI(3);
repeat I:= 0;
loop [repeat Ch:= ChIn(3) until Ch # CR; \remove possible CR
if Ch=LF or Ch=EOF then quit;
Word(I):= Ch;
I:= I+1;
];
Len:= I;
Word(I):= 0; \terminate string
if Es then [Text(0, Word); CrLf(0)];
until Ch = EOF;
]</lang>
 
{{out}}
<pre>
belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee
</pre>
772

edits