Change e letters to i in words: Difference between revisions
Content added Content deleted
(→{{header|haskell}}: Added a draft in Haskell) |
|||
Line 877: | Line 877: | ||
26: welles -> willis |
26: welles -> willis |
||
</pre> |
</pre> |
||
=={{header|haskell}}== |
|||
<lang haskell>import qualified Data.Set as S |
|||
------ DICTIONARY WORDS TWINNED BY e -> i REPLACEMENT ---- |
|||
ieTwins :: String -> [(String, String)] |
|||
ieTwins s = |
|||
[ (w, twin) |
|||
| w <- eligibles, |
|||
let twin = iForE w, |
|||
S.member twin lexicon |
|||
] |
|||
where |
|||
allWords = lines s |
|||
lexicon = S.fromList allWords |
|||
eligibles = |
|||
filter |
|||
(((&&) . (5 <) . length) <*> elem 'e') |
|||
allWords |
|||
iForE :: String -> String |
|||
iForE [] = [] |
|||
iForE ('e' : cs) = 'i' : iForE cs |
|||
iForE (c : cs) = c : iForE cs |
|||
--------------------------- TEST ------------------------- |
|||
main :: IO () |
|||
main = |
|||
readFile "unixdict.txt" |
|||
>>= (mapM_ print . ieTwins)</lang> |
|||
{{Out}} |
|||
<pre>("analyses","analysis") |
|||
("atlantes","atlantis") |
|||
("bellow","billow") |
|||
("breton","briton") |
|||
("clench","clinch") |
|||
("convect","convict") |
|||
("crises","crisis") |
|||
("diagnoses","diagnosis") |
|||
("enfant","infant") |
|||
("enquiry","inquiry") |
|||
("frances","francis") |
|||
("galatea","galatia") |
|||
("harden","hardin") |
|||
("heckman","hickman") |
|||
("inequity","iniquity") |
|||
("inflect","inflict") |
|||
("jacobean","jacobian") |
|||
("marten","martin") |
|||
("module","moduli") |
|||
("pegging","pigging") |
|||
("psychoses","psychosis") |
|||
("rabbet","rabbit") |
|||
("sterling","stirling") |
|||
("synopses","synopsis") |
|||
("vector","victor") |
|||
("welles","willis")</pre> |
|||
=={{header|jq}}== |
=={{header|jq}}== |