Find words with alternating vowels and consonants: Difference between revisions

m
Swift - use forEach instead of for loop
m (Prolog - removed unnecessary line)
m (Swift - use forEach instead of for loop)
Line 2,112:
 
do {
let words = try String(contentsOfFile: "unixdict.txt", encoding: String.Encoding.ascii)
let lines = words .components(separatedBy: "\n")
.filter{$0.count > 9 && alternatingVowelsAndConsonants(word: $0)}
for (n, word) in lines.filter(
{$0.count > 9 && alternatingVowelsAndConsonants(word: $0)}).enumerated() {
.forEach{print("\(String(format: "%2d. %@", n$0.0 + 1)):, \(word$0.1)")}
}
} catch {
print(error.localizedDescription)
1,777

edits