Last active
June 16, 2019 15:00
-
-
Save Adzz/166fa1b48bc196c0eddf9b6c12629678 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defimpl Zip, for: List do | |
def apply(a, b, operation) do | |
Enum.zip(a, b) | |
|> Enum.map(fn {a, b} -> operation.calculate(a, b) end) | |
end | |
end | |
# Now we can call it like this: | |
Zip.apply([1, 2], [3, 4], Add) #=> [4, 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment