Acronym

Acronym

Easy

Instructions

Convert a phrase to its acronym.

Techies love their TLA (Three Letter Acronyms)!

Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).

Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input.

For example:

Input Output
As Soon As Possible ASAP
Liquid-crystal display LCD
Thank George It's Friday! TGIF

This exercise works with textual data. For historical reasons, Haskell's String type is synonymous with [Char], a list of characters. For more efficient handling of textual data, the Text type can be used.

As an optional extension to this exercise, you can

  • Read about string types in Haskell.

  • Add - text to your list of dependencies in package.yaml.

  • Import Data.Text in the following way:

      import qualified Data.Text as T
      import           Data.Text (Text)
    
  • You can now write e.g. abbreviate :: Text -> Text and refer to Data.Text combinators as e.g. T.filter.

  • Look up the documentation for Data.Text.

This part is entirely optional.


Source

Julien VanierThe link opens in a new window or tab
Edit via GitHub The link opens in a new window or tab
Haskell Exercism

Ready to start Acronym?

Sign up to Exercism to learn and master Haskell with 105 exercises, and real human mentoring, all for free.

Deep Dive into Acronym!

We take a gentle dive into regular expressions starting with basic whitespace matching, exploring unicode, and ending with negative lookbehinds. We finish off by looking at some other approaches to Acronym including state machines.