Implement Secrets.secret_add/1. It should return a function which takes one argument and adds to it the argument passed in to secret_add.
Implement Secrets.secret_subtract/1. It should return a function which takes one argument and subtracts from it the secret passed in to secret_subtract.
Implement Secrets.secret_multiply/1. It should return a function which takes one argument and multiplies it by the secret passed in to secret_multiply.
Implement Secrets.secret_divide/1. It should return a function which takes one argument and divides it by the secret passed in to secret_divide.
Implement Secrets.secret_and/1. It should return a function which takes one argument and performs a bitwise and operation on it and the secret passed in to secret_and.
Implement Secrets.secret_xor/1. It should return a function which takes one argument and performs a bitwise xor operation on it and the secret passed in to secret_xor.
Implement Secrets.secret_combine/2. It should return a function which takes one argument and applies to it the two functions passed in to secret_combine in order.
https://exercism.org/tracks/elixir/exercises/secrets
use Bitwise
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
# &(trunc(&1 / secret))
&(div(&1, secret))
end
def secret_and(secret) do
&(&1 &&& secret)
end
def secret_xor(secret) do
&(bxor(secret, &1))
end
def secret_combine(secret_function1, secret_function2) do
&(secret_function2.(secret_function1.(&1)))
end
end