exercism/elixir/secrets/lib/secrets.ex

30 lines
506 B
Elixir
Raw Normal View History

2023-12-17 05:26:14 +00:00
defmodule Secrets do
def secret_add(secret) do
&(&1 + secret)
end
def secret_subtract(secret) do
&(&1 - secret)
end
def secret_multiply(secret) do
&(&1 * secret)
end
def secret_divide(secret) do
&(div(&1, secret))
end
def secret_and(secret) do
&(Bitwise.band(secret, &1))
end
def secret_xor(secret) do
&(Bitwise.bxor(secret, &1))
end
def secret_combine(secret_function1, secret_function2) do
&(secret_function2.(secret_function1.(&1)))
end
end