re: Daily Challenge #15 - Stop gninnipS My sdroW! VIEW POST

FULL DISCUSSION
 

Elixir:

defmodule Spinner do
  @spec spin(String.t()) :: String.t()
  def spin(sentence) do
    String.replace(sentence, ~r/\w+/, fn word ->
      if String.length(word) > 4 do
        String.reverse(word)
      else
        word
      end
    end)
  end
end

"Please spin me around!"
|> Spinner.spin()
|> IO.puts()

# => "esaelP spin me dnuora!"
code of conduct - report abuse