2.4 KiB
2.4 KiB
Hints
General
- Make use of anonymous functions.
- Use a closure to reference the variable from the outer scope.
1. Create an adder
- Return an anonymous function which adds the argument from the anonymous function to the argument passed in to
Secret.secret_add/1
.
2. Create a subtractor
- Return an anonymous function which subtracts the argument passed in to
Secret.secret_subtract/1
from the argument from the anonymous function.
3. Create a multiplier
- Return an anonymous function which multiplies the argument from the anonymous function to the argument passed in to
Secret.secret_multiply/1
.
4. Create a divider
- Return an anonymous function which divides the argument from the anonymous function by the argument passed in to
Secret.secret_divide/1
. - Make use of integer division.
5. Create an "and"-er
- Return an anonymous function which performs a bitwise and operation using the argument passed in to the anonymous function and the argument passed in to
Secret.secret_and/1
- Functions in the Bitwise module may be of use.
- If you are running Elixir version 1.9 or lower, you will need to call
require Bitwise
at the beginning of the module definition to be able to use the Bitwise module.
6. Create an "xor"-er
- Return an anonymous function which performs a bitwise xor operation using the argument passed in to the anonymous function and the argument passed in to
Secret.secret_xor/1
- Functions in the Bitwise module may be of use.
- If you are running Elixir version 1.9 or lower, you will need to call
require Bitwise
at the beginning of the module definition to be able to use the Bitwise module.
7. Create a function combiner
- Return an anonymous function which composes the functions passed in to
Secret.secret_combine/2
. - Use a
.
before()
when calling an anonymous function.