Each of this lines will return nil from its implicit else branch.
I am not sure though, why your result is ["wink", nil], it should be ["wink" | nil].
You should try to do some other approach by creating a list of tuples, where the first element is the bit that has to be set, the other is the word to put in the command. Then you simply fold over that list.
Something like this:
[{0, "wink"}, {1, "double blink"}, {2, "close your eyes"}, {3, "jump"}]
|> Enum.fold([], fn {bit, cmd}, acc ->
if bit_set?(code, bit), do: [cmd | acc], else: acc
end)
|> Enum.reverse()
bit_set?/2 is easily implementable using the Bitwise module.






















