Find words with alternating vowels and consonants: Difference between revisions
Find words with alternating vowels and consonants (view source)
Revision as of 00:19, 8 April 2021
, 3 years agoAda version
m (→{{header|REXX}}: added/changed comments, changed whitespace.) |
(Ada version) |
||
Line 10:
{{Template:Strings}}
<br><br>
=={{header|Ada}}==
<lang Ada>with Ada.Text_Io;
with Ada.Strings.Fixed;
procedure Find_Alternating is
use Ada.Text_Io;
function Is_Vowel (Letter : Character) return Boolean
is (Ada.Strings.Fixed.Index ("aeiou", "" & Letter) /= 0);
Filename : constant String := "unixdict.txt";
File : File_Type;
begin
Open (File, In_File, Filename);
while not End_Of_File (File) loop
declare
Word : constant String := Get_Line (File);
First : Boolean := True;
Failed : Boolean := False;
Vowel : Boolean;
begin
for Letter of Word loop
if First then
Vowel := Is_Vowel (Letter);
First := False;
else
if Vowel = Is_Vowel (letter) then
Failed := True;
exit;
end if;
Vowel := not Vowel;
end if;
end loop;
if not Failed and Word'Length > 9 then
Put_Line (Word);
end if;
end;
end loop;
Close (File);
end Find_Alternating;</lang>
=={{header|ALGOL 68}}==
|