elixir-in-action/circle.ex

13 lines
317 B
Elixir
Raw Normal View History

2020-06-20 13:57:33 -05:00
defmodule Circle do
@moduledoc "Implements basic circle functions"
@pi 3.14159
@doc "Computes the area of a circle"
@spec area(number) :: number
def area(r), do: r * r * @pi
@doc "Computes the circumferenc of a circle"
@spec circumference(number) :: number
def circumference(r), do: 2 * r * @pi
end