Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created March 12, 2012 12:29
Show Gist options
  • Save mizchi/2021524 to your computer and use it in GitHub Desktop.
Save mizchi/2021524 to your computer and use it in GitHub Desktop.
defmodule Hello do
def world do
IO.puts "hello"
end
end
defmodule Fib do
def fib(0) do 0 end
def fib(1) do 1 end
def fib(n) do fib(n-1)+fib(n-2) end
end
defmodule Q do
def sort([]) do [] end
def sort([h|tail]) do
a = []
b = []
Enum.map tail, fn(x)->
if x < h do
a = a++[x]
else:
b = b++[x]
end
end
IO.puts a
IO.puts b
sort(a)++[h]++sort(b)
end
end
Hello.world
IO.puts Fib.fib(11)
IO.puts Q.sort [4,2,3,8,5,4,7,9,2,5,2,7]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment