Skip to content

Instantly share code, notes, and snippets.

@terinjokes
Last active December 30, 2015 23:08
Show Gist options
  • Save terinjokes/69f9ad628dfa1265ef47 to your computer and use it in GitHub Desktop.
Save terinjokes/69f9ad628dfa1265ef47 to your computer and use it in GitHub Desktop.
Simple Elixir lambda example
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