mirror of
https://github.com/rjNemo/exercism-elixir
synced 2026-06-06 10:26:48 +00:00
17 lines
560 B
Elixir
17 lines
560 B
Elixir
defmodule Bob do
|
|
@spec hey(String.t()) :: String.t()
|
|
def hey(input) do
|
|
letter? = &(String.upcase(&1) != String.downcase(&1))
|
|
shouting? = &(&1 == String.upcase(&1) and letter?.(&1))
|
|
question? = &(String.trim(&1) |> String.ends_with?("?"))
|
|
blank? = &(String.trim(&1) == "")
|
|
|
|
cond do
|
|
blank?.(input) -> "Fine. Be that way!"
|
|
shouting?.(input) and question?.(input) -> "Calm down, I know what I'm doing!"
|
|
shouting?.(input) -> "Whoa, chill out!"
|
|
question?.(input) -> "Sure."
|
|
true -> "Whatever."
|
|
end
|
|
end
|
|
end
|