First commit

This commit is contained in:
Mariano Uvalle 2020-06-20 13:57:33 -05:00
commit 1dba0af064
36 changed files with 1065 additions and 0 deletions

30
geometry.ex Normal file
View file

@ -0,0 +1,30 @@
defmodule Geometry do
def rectangle_area(a, b) do
a * b
end
def rectangle_area_condensed(a, b), do: a * b
end
defmodule Rectangle do
def area(a, b), do: a * b
def area(a), do: area(a, a)
end
defmodule GeometryMultiClause do
def area({:rectangle, a, b}) do
a * b
end
def area({:square, a}) do
a * a
end
def area({:circle, r}) do
r * r * 3.14159
end
def area(unknown) do
{:error, {:unkown_shape, unknown}}
end
end