Genetic Algorithms in Elixir: non updated code for run/4 function (page 28)

The code of the run/4 function at the bottom of page 28 is not updated with the opts param in the inner function calls:

Finally, pass opts to every function in run and evolve :

def run(genotype, fitness_function, max_fitness, opts \\ []) do
  population = initialize(genotype)
  population
  |> evolve(fitness_function, max_fitness)
  end

should read:

def run(genotype, fitness_function, max_fitness, opts \\ []) do
  population = initialize(genotype, opts)
  population
  |> evolve(fitness_function, max_fitness, opts)
end

(I’m really enjoying the book! :smile:)

1 Like

Thanks again! I’ll fix this one too. Glad you’re enjoying the book!

2 Likes