Sha256: 3035ce830f4c96e63f34d97e73e4929628cda891aa266e4780913213d68c25d6
Contents?: true
Size: 496 Bytes
Versions: 254
Compression:
Stored size: 496 Bytes
Contents
module Acronym (abbreviate) where import Data.Char (isAlpha, isUpper, toUpper) abbreviate :: String -> String abbreviate = concatMap initials . words . map replaceNonAlpha initials :: String -> String initials [] = [] initials (x:xs) = toUpper x : rest where rest = if not $ isAcronym xs then filter isUpper xs else [] isAcronym :: String -> Bool isAcronym = all isUpper replaceNonAlpha :: Char -> Char replaceNonAlpha x | isAlpha x = x | otherwise = ' '
Version data entries
254 entries across 254 versions & 1 rubygems