Find words with alternating vowels and consonants: Difference between revisions

Add Seed7
(→‎{{header|Factor}}: Add a short explanation of the code.)
(Add Seed7)
Line 2,444:
verisimilitude
</pre>
 
=={{header|Seed7}}==
<lang seed7>$include "seed7_05.s7i";
 
const func boolean: vowel (in char: letter) is
return letter in {'A', 'E', 'I', 'O', 'U'} |
{'a', 'e', 'i', 'o', 'u'};
const func boolean: consonant (in char: letter) is
return letter in {'B', 'C', 'D'} | {'F', 'G', 'H'} |
{'J' .. 'N'} | {'P' .. 'T'} | {'V' .. 'Z'} |
{'b', 'c', 'd'} | {'f', 'g', 'h'} |
{'j' .. 'n'} | {'p' .. 't'} | {'v' .. 'z'};
 
const func boolean: opposite (in char: letter1, in char: letter2) is
return vowel(letter1) and consonant(letter2) or
(consonant(letter1) and vowel(letter2));
 
const func boolean: alternating (in string: word) is func
result
var boolean: isAlternating is TRUE;
local
var integer: i is 2;
begin
while i <= length(word) and isAlternating do
isAlternating := opposite(word[i - 1], word[i]);
incr(i);
end while;
end func;
 
const proc: main is func
local
var file: dictionary is STD_NULL;
var string: word is "";
var integer: count is 1;
begin
dictionary := open("unixdict.txt", "r");
if dictionary <> STD_NULL then
while not eof(dictionary) do
readln(dictionary, word);
if length(word) > 9 and alternating(word) then
writeln(count lpad 2 <& ": " <& word);
incr(count);
end if;
end while;
close(dictionary);
end if;
end func;</lang>
{{out}}
<pre style="height:36em">
1: aboriginal
2: apologetic
3: bimolecular
4: borosilicate
5: calorimeter
6: capacitate
7: capacitive
8: capitoline
9: capitulate
10: caricature
11: colatitude
12: coloratura
13: colorimeter
14: debilitate
15: decelerate
16: decolonize
17: definitive
18: degenerate
19: deliberate
20: demodulate
21: denominate
22: denotative
23: deregulate
24: desiderata
25: desideratum
26: dilapidate
27: diminutive
28: epigenetic
29: facilitate
30: hemosiderin
31: heretofore
32: hexadecimal
33: homogenate
34: inoperative
35: judicature
36: latitudinal
37: legitimate
38: lepidolite
39: literature
40: locomotive
41: manipulate
42: metabolite
43: nicotinamide
44: oratorical
45: paragonite
46: pejorative
47: peridotite
48: peripatetic
49: polarimeter
50: recitative
51: recuperate
52: rehabilitate
53: rejuvenate
54: remunerate
55: repetitive
56: reticulate
57: savonarola
58: similitude
59: solicitude
60: tananarive
61: telekinesis
62: teratogenic
63: topologize
64: unilateral
65: unimodular
66: uninominal
67: verisimilitude
</pre>
 
=={{header|Swift}}==
<lang swift>import Foundation
1,808

edits