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

Version Path
trackler-2.2.1.180 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.179 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.178 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.177 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.176 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.175 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.174 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.173 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.172 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.171 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.170 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.169 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.167 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.166 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.165 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.164 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.163 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.162 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.161 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.160 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs