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.139 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.138 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.137 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.136 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.135 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.134 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.133 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.132 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.131 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.130 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.129 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.128 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.127 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.126 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.125 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.124 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.123 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.122 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.121 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.120 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs