defmodule Shape do
def area({:circle, r}) when is_number(r) and r >= 0, do: 3.14159 * r * r
def area({:rect, w, h}) when is_number(w) and is_number(h), do: w * h
def area(other), do: {:error, {:unknown_shape, other}}
end
IO.inspect(Shape.area({:circle, 2}))
IO.inspect(Shape.area({:rect, 3, 4}))
IO.inspect(Shape.area({:circle, -1}))
12.56636
12
{:error, {:unknown_shape, {:circle, -1}}}