Created
December 15, 2015 18:45
-
-
Save bryanwoods/b6b9ae0b0a39d4a82b2e 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 MyList do | |
def map([], _), do: [] | |
def map([head | tail], func), do: [func.(head) | map(tail, func)] | |
def sum([], total), do: total | |
def sum([head | tail], total), do: sum(tail, head + total) | |
def mapsum([], _), do: 0 | |
def mapsum(list, func), do: sum(map(list, func), 0) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment