Genetic Algorithms in Elixir: Chapter 6: Misplaced parenthesis in fitness_function (page 90)

Seems that in the line:

|> Kernel.-(Enum.at(chromosome.genes), j)

the closing parens (after genes) is misplaced.
should probably be

|> Kernel.-(Enum.at(chromosome.genes, j))

Otherwise we get a

** (UndefinedFunctionError) function Enum.at/1 is undefined or private. Did you mean one of:

      * at/2
      * at/3

    (elixir 1.10.3) Enum.at([3, 7, 5, 2, 1, 0, 6, 4])
    scripts/n_queens.exs:21: anonymous fn/4 in NQueens.fitness_function/1
1 Like