Created
February 5, 2018 18:05
-
-
Save allenyang79/ee03f42e55b31b613b2ee078af6a151b 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
ExUnit.start | |
defmodule Test do | |
use ExUnit.Case | |
@moduledoc """ | |
Run with test | |
## Examples | |
elixir test.exs | |
""" | |
defp is_odd?(n), do: rem(n, 2) == 1 | |
defp is_even?(n), do: rem(n, 2) == 0 | |
def my_filter(:is_odd, arr) do | |
Enum.filter(arr, &is_odd?/1) | |
end | |
def my_filter(:is_even, arr) do | |
Enum.filter(arr, &is_even?/1) | |
end | |
test "assert is_odd" do | |
my_filter(:is_odd, [1,2,3,4]) == [1, 3] | |
end | |
test "assert is_even" do | |
my_filter(:is_even, [1,2,3,4]) == [2, 4] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment