Skip to content

Commit

Permalink
remove add_to_sorted/2
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeyson committed Oct 29, 2022
1 parent c2bee3a commit 467d199
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/algox/walk_on_matrix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule WalkOnMatrix do
defp sort([head | tail], unsorted_rows, sorted_row) when tail === [] do
[last_elem | rest] = segregate_last_elem(head, [])
sorted_row = [last_elem | sorted_row]
sorted_row = add_to_sorted(rest, sorted_row)
sorted_row = reverse_row(rest, sorted_row)

sort(unsorted_rows, [], sorted_row)
end
Expand All @@ -44,12 +44,6 @@ defmodule WalkOnMatrix do
sort(tail, unsorted_rows, sorted_row)
end

defp add_to_sorted([], sorted), do: sorted

defp add_to_sorted([head | tail], sorted) do
add_to_sorted(tail, [head | sorted])
end

defp reverse_row([], reversed_row), do: reversed_row

defp reverse_row([head | tail], reversed_row) do
Expand Down

0 comments on commit 467d199

Please sign in to comment.