ŹR
Size: a a a
ŹR
DR
DR
ŹR
ŹR
ŹR
ŹR
client:%ID% каналŹR
ClientCanal вся логикаŹR
ŹR
ŹR
DR
ŹR
ŹR
ŹR
ŹR
ŹR
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
IK