Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created February 6, 2015 15:18
Show Gist options
  • Save guilleiguaran/2eb32f8bee5dfc95727f to your computer and use it in GitHub Desktop.
Save guilleiguaran/2eb32f8bee5dfc95727f to your computer and use it in GitHub Desktop.
defmodule Enum do
def map([], _fun), do: []
def map([head | tail], fun) do
[fun.(head) | map(tail)]
end
def reduce([], acc, _fun), do: acc
def reduce([head | tail], acc, fun) do
reduce(tail, fun.(head, acc), fun)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment