Created
August 18, 2015 17:38
-
-
Save chooblarin/dc872c5cc7d7ba09cb3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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