Abbreviations, automatic: Difference between revisions

(→‎{{header|Haskell}}: Used Data.Set)
Line 2,839:
 
=={{header|Haskell}}==
<lang haskell>import Data.List (inits, intercalate, nub, transpose)
import qualified Data.Set as S
 
---------------------- ABBREVIATIONSMINIMUM ABBREVIATION LENGTH ---------------------
 
abbrevnsminAbbrevnLength :: [String] -> [String]Int
minAbbrevlnLength [] = 0
abbrevns xs
| nullminAbbrevnLength xs = []
length . head . S.toList . head $
| otherwise =
dropWhile ((< n) . S.size) $
head $
dropWhile ((< n) S. length) $fromList
nub<$> transpose (inits <$> xs)
<$> transpose (inits <$> xs)
where
n = length xs
 
 
--------------------------- TEST -------------------------
Line 2,863 ⟶ 2,862:
intercalate "\t"
. (<*>)
[ show . length . head . abbrevnsminAbbrevnLength . words,
id
]
9,655

edits