-
-
Couldn't load subscription status.
- Fork 405
Description
I was just trying to solve the "Darts" exercise. The hints include the correct formula to get the distance from origin to any given coordinate on a plane, but the provided workaround for the lack of a native square root function in elixir doesn't seem to work. The spec for Integer.pow() is expecting integers for both the base and the exponent arguments. The spec for Float.pow() is explicitly expecting a float for the base, and a number for the exponent.
For the first test case of (-9, 9)
iex(3)> -9 * -9 + 9 * 9
162
iex(4)> Integer.pow(162, 0.5)
** (FunctionClauseError) no function clause matching in Integer.pow/2
The following arguments were given to Integer.pow/2:
# 1
162
# 2
0.5
Attempted function clauses (showing 1 out of 1):
def pow(base, exponent) when is_integer(base) and is_integer(exponent)
(elixir 1.16.0) lib/integer.ex:105: Integer.pow/2
iex:4: (file)
iex(4)> Float.pow(162, 0.5)
** (FunctionClauseError) no function clause matching in Float.pow/2
The following arguments were given to Float.pow/2:
# 1
162
# 2
0.5
Attempted function clauses (showing 1 out of 1):
def pow(base, exponent) when is_float(base) and is_number(exponent)
(elixir 1.16.0) lib/float.ex:116: Float.pow/2
iex:4: (file)
iex(4)>
Checking the example.ex in the repo, I see that neither Integer.pow or Float.pow were used there, but rather the erlang math library. I'm apologize if I am missing something else, as I'm not great at geometry OR elixir.