Created
February 6, 2015 15:18
-
-
Save guilleiguaran/2eb32f8bee5dfc95727f to your computer and use it in GitHub Desktop.
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 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