aboutsummaryrefslogtreecommitdiff
path: root/lib/elixir_math_parser.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elixir_math_parser.ex')
-rw-r--r--lib/elixir_math_parser.ex12
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/elixir_math_parser.ex b/lib/elixir_math_parser.ex
index b5e99bd..4d48065 100644
--- a/lib/elixir_math_parser.ex
+++ b/lib/elixir_math_parser.ex
@@ -68,19 +68,13 @@ defmodule ElixirMathParser do
end
end
- #  Functions for maths
+ # Functions for maths
defp factor(n, acc) when n > 0, do: factor(n - 1, acc * n)
defp factor(0, acc), do: acc
- defp expo(value, exponent, acc) when exponent != 0 do
- if exponent > 0 do
- expo(value, exponent - 1, acc * value)
- else
- expo(value, exponent + 1, acc / value)
- end
- end
-
+ defp expo(value, exponent, acc) when exponent > 0, do: expo(value, exponent - 1, acc * value)
+ defp expo(value, exponent, acc) when exponent < 0, do: expo(value, exponent + 1, acc / value)
defp expo(_value, 0, acc), do: acc
defp evaluate_tree([{:assign, {:var, line, lhs}, rhs} | tail], state) do