2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,9 +1,9 @@
defmodule Sort do
def gnome_sort(list) when length(list) <= 1, do: list
def gnome_sort([]), do: []
def gnome_sort([h|t]), do: gnome_sort([h], t)
defp gnome_sort(list, []), do: list
defp gnome_sort([prev|p], [next|n]) when next > prev, do: gnome_sort(p, [next|[prev|n]])
defp gnome_sort([prev|p], [next|n]) when next > prev, do: gnome_sort(p, [next,prev|n])
defp gnome_sort(p, [next|n]), do: gnome_sort([next|p], n)
end