Here's the real beginner question ...
In a for loop, when are the loop parameters calculated?
Here the loop runs forever, so c is obviously βcheckedβ every time the loop starts:
c= [1] for i in c push!(c, i) @show c end c = [1,1] c = [1,1,1] c = [1,1,1,1] ...
But this cycle is evaluated only once:
c= [1] for i in 1:length(c) push!(c, i) @show c end c = [1,1]
It seems to evaluate enumerate(c) every cycle:
c= [1] for (i, _) in enumerate(c) push!(c, i) @show c end c = [1,1] c = [1,1,1] c = [1,1,1,1] ...
But this loop obviously does not:
c= [1] for i in eachindex(c) push!(c, i) @show c end c = [1,1]
And it does:
c= [1] foreach(a -> (push!(c, a); @show c), c) c = [1,1] c = [1,1,1] c = [1,1,1,1] ...
As I said, this is a real question for beginners. But am I missing a common template?