This commit is contained in:
2024-03-11 11:44:09 -04:00
parent d46a9b8e9a
commit 22b46519fd
10 changed files with 281 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
defmodule Acronym do
@doc """
Generate an acronym from a string.
"This is a string" => "TIAS"
"""
@spec abbreviate(String.t()) :: String.t()
def abbreviate(string) do
string
|> String.split([" ", "-", "_"], trim: true)
|> Enum.map(&String.first/1)
|> Enum.join()
|> String.upcase()
end
end