Sorry if this is a dumb question; I just started my first real Nim project a
few days ago. Why does this proc yield Error: 'crossover' can have side effects?
import random
func crossover*[T](parent_1: seq[T], parent_2: seq[T]): (seq[T], seq[T]) =
## The default crossover function.
## Takes two parents and chooses a random index at which to recombine
them.
let idx = rand(0..<parent_1.high)
return (parent_1[0..idx] & parent_2[idx+1..parent_2.high],
parent_2[0..idx] &
parent_1[idx+1..parent_1.high])
echo crossover(@[1, 2, 3], @[4, 5, 6])
Run
>From looking at it, it doesn't modify anything, so I can't figure out why it
>is giving the side effect error? Does instantiating the idx variable cause the
>error?