You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd be also interesting to search for solutions without using any module.
defmodule Span do
def sort(list, whatever_function) do
whileright(list, whatever_function, [])
end
defp whileright([head | tail], whatever_function, good) do
case whatever_function.(head) do
true -> whileright(tail, whatever_function, good ++ [head])
false -> {good, [head] ++ tail}
end
end
defp whileright([], _, good) do
{good, []}
end
end
The text was updated successfully, but these errors were encountered:
I'd be also interesting to search for solutions without using any module.
defmodule Span do
def sort(list, whatever_function) do
whileright(list, whatever_function, [])
end
defp whileright([head | tail], whatever_function, good) do
case whatever_function.(head) do
true -> whileright(tail, whatever_function, good ++ [head])
false -> {good, [head] ++ tail}
end
end
defp whileright([], _, good) do
{good, []}
end
end
The text was updated successfully, but these errors were encountered: