Find words with alternating vowels and consonants: Difference between revisions

Content added Content deleted
(→‎AppleScript :: Functional: Refactored to generate two listings – aeiou and also aeiouy)
Line 159: Line 159:


-- alternatingWordQuery :: String -> String
-- alternatingWordQuery :: String -> String
on alternatingWordQuery(regex)
on alternatingWordQuery(vowels)
set regex to "^.*([" & vowels & "]{2}|[^" & vowels & "]{2}).*$"
"(9 < self.length) and not (self matches '" & regex & "')"
"(9 < self.length) and not (self matches '" & regex & "')"
end alternatingWordQuery
end alternatingWordQuery


-- pairRegex :: String -> String
on pairRegex(vowels)
"^.*([" & vowels & "]{2}|[^" & vowels & "]{2}).*$"
end pairRegex




Line 174: Line 170:
script
script
on |λ|(vowels)
on |λ|(vowels)
set query to alternatingWordQuery(pairRegex(vowels))
set query to alternatingWordQuery(vowels)
set matches to filteredLines(query, lexicon)
set matches to filteredLines(query, lexicon)
Line 201: Line 197:
end if
end if
end run
end run