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).
Julien Vanier https://github.com/monkbroc
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
module Test.Main where import Prelude import Acronym (abbreviate) import Effect (Effect) import Test.Unit (TestSuite, suite, test) import Test.Unit.Assert as Assert import Test.Unit.Main (runTest) main :: Effect Unit main = runTest suites suites :: TestSuite suites = do suite "Acronym.abbreviate" do test "acronyms from title case" $ Assert.equal "PNG" $ abbreviate "Portable Networks Graphic" test "acronyms from lower case" $ Assert.equal "ROR" $ abbreviate "Ruby on Rails" test "acronyms from inconsistent case" $ Assert.equal "HTML" $ abbreviate "HyperText Markup Language" test "punctuation is ignored" $ Assert.equal "FIFO" $ abbreviate "First in, First out" test "acronyms ignoring punctuation and casing" $ Assert.equal "CMOS" $ abbreviate "Complementary Metal-Oxide semiconductor"
module Acronym ( abbreviate ) where import Prelude (($), map, flip) import Data.Array.NonEmpty (NonEmptyArray, toArray) import Data.Maybe (Maybe(..), fromMaybe) import Data.String (joinWith, toUpper) import Data.String.Regex (match) import Data.String.Regex.Flags (global) import Data.String.Regex.Unsafe (unsafeRegex) abbreviate :: String -> String abbreviate s = toUpper $ joinWith "" $ importantLetters s importantLetters :: String -> Array String importantLetters s = toStringArray $ flip match s $ unsafeRegex pattern global where pattern = "\\b\\w|[A-Z]" toStringArray :: Maybe (NonEmptyArray (Maybe String)) -> Array String toStringArray Nothing =  toStringArray (Just a) = map (fromMaybe "") $ toArray a
A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.
Here are some questions to help you reflect on this solution and learn the most from it.