-
-
Save lovesegfault/c858a83b4960a8bbc11ca9c5229b1983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Acronym (abbreviate) where | |
import Data.Char (isSpace, isUpper) | |
import Data.Text (Text) | |
import qualified Data.Text as T | |
abbreviate :: Text -> Text | |
abbreviate = | |
T.toUpper | |
. T.concat | |
. map (\w -> T.take 1 w <> (T.filter isUpper . T.dropWhile isUpper) w) | |
. T.split (\c -> isSpace c || c `elem` ['-', '_']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment