The code:
require Formulae.Combinators
def permutations(trains, train_stations)
when is_list(trains) and
is_list(train_stations) do
number_of_trains = length(trains)
Formulae.Combinators.permutations(train_stations, number_of_trains)
end
The error:
** (ArgumentError) ranges (first..last) expect both sides to be integers, got:
{:number_of_trains, [line: 86], nil}..1
(elixir 1.10.2) lib/range.ex:63: Range.new/2
expanding macro: Formulae.Combinators.permutations/2
lib/trains.ex:86: Trains.permutations/2
But https://hexdocs.pm/formulae/Formulae.Combinators.html says the in permutations(l, n) n should be an integer and length(trains) returns an integer. Formulae.Combinators.permutations(train_stations, 2) works fine.
What is my mistake? How can I fix it?