Skip to content

Instantly share code, notes, and snippets.

@chooblarin
Created August 18, 2015 17:38
Show Gist options
  • Save chooblarin/dc872c5cc7d7ba09cb3a to your computer and use it in GitHub Desktop.
Save chooblarin/dc872c5cc7d7ba09cb3a to your computer and use it in GitHub Desktop.
defmodule Prac1 do
def fib(0) do 0 end
def fib(1) do 1 end
def fib(n) do fib(n-1) + fib(n-2) end
def qsort([]) do [] end
def qsort([h|tail]) do
{left, right} = Enum.partition(tail, &(&1 < h))
qsort(left) ++ [h] ++ qsort(right)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment