Last active
December 30, 2015 23:08
-
-
Save terinjokes/69f9ad628dfa1265ef47 to your computer and use it in GitHub Desktop.
Simple Elixir lambda example
This file contains 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
defmodule FooBar do | |
def update_header(headers, key, fun) do | |
if List.keymember?(headers, key, 0) do | |
value = fun.(headers) | |
List.keystore(headers, key, 0, {key, value}) | |
else | |
value = fun.(nil) | |
List.keystore(headers, key, 0, {key, value}) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment