xikaos
7/29/2016 - 5:57 PM

regular-languages-palindrome-string.exs

defmodule Palindromes do
  def run do
    ["amor", "roma", "phoenix", "mora", "elixir"]
    |> Enum.group_by(&canonicalize/1)
    |> IO.inspect
  end

  defp canonicalize(word) do
    word
    |> String.graphemes
    |> Enum.sort
    |> Enum.join
  end
end

Palindromes.run