18 lines
378 B
Elixir
18 lines
378 B
Elixir
defmodule AllYourBase do
|
|
@doc """
|
|
Given a number in base a, represented as a sequence of digits, converts it to base b,
|
|
or returns nil if either of the bases are less than 2
|
|
"""
|
|
|
|
@spec convert(list, integer, integer) :: list
|
|
def convert(digits, base_a, base_b) do
|
|
cond do
|
|
base_a < 2 || base_b < 2 ->
|
|
nil
|
|
|
|
true ->
|
|
""
|
|
end
|
|
end
|
|
end
|