Last active
October 12, 2015 12:58
-
-
Save dskecse/88d93eb9037bf57abc10 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 MyEnum do | |
def all?([head | tail], func \\ fn x -> x end) do | |
func.(head) && all?(tail, func) | |
end | |
def all?([], _), do: true | |
def each([], _), do: [] | |
def each([head | tail], func) do | |
[func.(head), each(tail, func)] | |
end | |
# TODO: do something with unflatten lists | |
def filter([], _), do: nil | |
def filter([head | tail], func) when func.(head) == true do | |
[head, filter(tail, func)] | |
end | |
def filter([head | tail], func) when func.(head) == false do | |
[filter(tail, func)] | |
end | |
def split | |
def take | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment