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.98 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.97 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.96 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.95 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.94 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.93 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.92 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.91 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.90 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.89 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.88 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.87 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.86 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.85 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.84 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.83 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.82 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.81 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.80 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs
trackler-2.2.1.79 tracks/haskell/exercises/acronym/examples/success-standard/src/Acronym.hs