Find words with alternating vowels and consonants: Difference between revisions

Added XPL0 example.
No edit summary
(Added XPL0 example.)
Line 3,237:
66: uninominal
67: verisimilitude
</pre>
 
=={{header|XPL0}}==
<lang XPL0>string 0; \Use zero-terminated strings
int Cnt, I, Ch, Len;
char Word(100); \(longest word in unixdict.txt is 22 chars)
def Tab=$09, LF=$0A, CR=$0D, EOF=$1A;
 
func Vowel(Ch); \Return 'true' if character is a vowel
int Ch;
case Ch of ^a, ^e, ^i, ^o, ^u: return true
other return false;
 
func Alternates; \Return 'true' if Word alternates vowel/consonant
int Sense, I;
[Sense:= Vowel(Word(0));
for I:= 0 to Len-1 do
[if Vowel(Word(I)) # Sense then return false;
Sense:= not Sense;
];
return true;
];
 
[FSet(FOpen("unixdict.txt", 0), ^I); \open dictionary and set it to device 3
OpenI(3);
Cnt:= 0;
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;
];
Word(I):= 0; \terminate string
Len:= I;
if Len > 9 then
[if Alternates then
[Text(0, Word);
Cnt:= Cnt+1;
if rem(Cnt/5) then ChOut(0, Tab) else CrLf(0);
];
];
until Ch = EOF;
]</lang>
 
{{out}}
<pre>
aboriginal apologetic bimolecular borosilicate calorimeter
capacitate capacitive capitoline capitulate caricature
colatitude coloratura colorimeter debilitate decelerate
decolonize definitive degenerate deliberate demodulate
denominate denotative deregulate desiderata desideratum
dilapidate diminutive epigenetic facilitate hemosiderin
heretofore hexadecimal homogenate inoperative judicature
latitudinal legitimate lepidolite literature locomotive
manipulate metabolite nicotinamide oratorical paragonite
pejorative peridotite peripatetic polarimeter recitative
recuperate rehabilitate rejuvenate remunerate repetitive
reticulate savonarola similitude solicitude tananarive
telekinesis teratogenic topologize unilateral unimodular
uninominal verisimilitude
</pre>
772

edits