Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,10 @@
|
|||
defmodule Sort do
|
||||
def gnome_sort(list) when length(list) <= 1, do: list
|
||||
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(p, [next|n]), do: gnome_sort([next|p], n)
|
||||
end
|
||||
|
||||
IO.inspect Sort.gnome_sort([8,3,9,1,3,2,6])
|
||||
Loading…
Add table
Add a link
Reference in a new issue