Е
Size: a a a
Е
Е
AM
def map_error_first(list, function) do
map_error_first(list, function, [])
end
def map_error_all(list, function) do
map_error_all(list, function, :ok, [])
end
defp map_error_all([], _, status, acc) do
{status, Enum.reverse(acc)}
end
defp map_error_all([elem | list], function, :ok, acc) do
case function.(elem) do
{:ok, new_elem} ->
map_error_all(list, function, :ok, [new_elem | acc])
{:error, new_elem} ->
map_error_all(list, function, :error, [new_elem])
end
end
defp map_error_all([elem | list], function, :error, acc) do
case function.(elem) do
{:ok, _new_elem} ->
map_error_all(list, function, :error, acc)
{:error, new_elem} ->
map_error_all(list, function, :error, [new_elem | acc])
end
end
defp map_error_first([], _, acc), do: {:ok, Enum.reverse(acc)}
defp map_error_first([elem | list], function, acc) do
case function.(elem) do
{:ok, new_elem} ->
map_error_first(list, function, [new_elem | acc])
{:error, error} ->
{:error, error}
end
end
ŹR
ŹR
АП
driverhub@driverhub:~/tmp/taxi$ asdf list erlang
21.0
driverhub@driverhub:~/tmp/taxi$ asdf list elixir
1.7.3-otp-21
АП
AK
ŹR
ŹR
AM
ŹR
ŹR
AM
AM
ŹR
ŹR
АП