This commit is contained in:
2024-03-10 08:14:17 -04:00
parent 3c7f1d64f5
commit c625ecedd6
10 changed files with 418 additions and 0 deletions

23
elixir/bob/lib/bob.ex Normal file
View File

@@ -0,0 +1,23 @@
defmodule Bob do
@spec hey(String.t()) :: String.t()
def hey(input) do
trimmed = String.trim(input)
is_yell? = String.upcase(trimmed) == trimmed and String.downcase(trimmed) != trimmed
is_question? = String.ends_with?(trimmed, "?")
is_silence? = trimmed == ""
cond do
is_silence? ->
"Fine. Be that way!"
is_yell? and is_question? ->
"Calm down, I know what I'm doing!"
is_question? ->
"Sure."
is_yell? ->
"Whoa, chill out!"
true ->
"Whatever."
end
end
end