Skip to content

Instantly share code, notes, and snippets.

@bryanwoods
Created December 15, 2015 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanwoods/b6b9ae0b0a39d4a82b2e to your computer and use it in GitHub Desktop.
Save bryanwoods/b6b9ae0b0a39d4a82b2e to your computer and use it in GitHub Desktop.
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