Sha256: cc0eb46afb783f5b08736ffc14baf0494fc8acc1626df4408cf430f8583b3fae

Contents?: true

Size: 263 Bytes

Versions: 69

Compression:

Stored size: 263 Bytes

Contents

defmodule Acronym do
  @spec abbreviate(String.t()) :: String.t()
  def abbreviate(string) do
    Regex.scan(~r/[A-Z]+[a-z]*|[a-z]+/, string)
    |> List.flatten()
    |> Enum.map(fn x -> String.first(x) end)
    |> Enum.join("")
    |> String.upcase()
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.179 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.178 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.177 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.176 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.175 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.174 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.173 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.172 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.171 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.170 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.169 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.167 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.166 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.165 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.164 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.163 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.162 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.161 tracks/elixir/exercises/acronym/example.exs
trackler-2.2.1.160 tracks/elixir/exercises/acronym/example.exs