defmodule Kvadra do
def kvadratic(a,b,c) do
disc = discrim(a,b,c)
case disc do
_ when disc > 0 -> two_roots(a,b,disc)
0 -> one_root(a,b)
_ -> "Diskriminant je zaportny - zadne realne koreny."
end
end
defp discrim(a,b,c), do: b * b - 4 * a * c
defp one_root(a, b), do: {-b / (2 * a)}
defp two_roots(a,b,disc) do
root1 = (-b + :math.sqrt(disc)) / (2 * a)
root2 = (-b - :math.sqrt(disc)) / (2 * a)
{root1, root2}
end
end
IO.inspect(Kvadra.kvadratic(2,6,-20))