June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,10 +1,17 @@
import qualified Data.Set as S
semordnilaps = snd . foldl f (S.empty,[]) where
f (s,w) x | S.member (reverse x) s = (s, x:w)
| otherwise = (S.insert x s, w)
semordnilaps
:: (Ord a, Foldable t)
=> t [a] -> [[a]]
semordnilaps =
let f x (s, w)
| S.member (reverse x) s = (s, x : w)
| otherwise = (S.insert x s, w)
in snd . foldr f (S.empty, [])
main=do s <- readFile "unixdict.txt"
let l = semordnilaps (lines s)
print $ length l
mapM_ print $ map (\x->(x, reverse x)) $ take 5 l
main :: IO ()
main = do
s <- readFile "unixdict.txt"
let l = semordnilaps (lines s)
print $ length l
mapM_ (print . ((,) <*> reverse)) $ take 5 l