Iteration in Julia can be achieved for certain new types of iteration by implementing an interface which has 3 functions: start, next,done
I do not see an exclamation mark at the end of these functions, so from my understanding of julia naming conventions, these 3 functions should not change their arguments. In particular, these two loops should give the same output.
state = start(iter)
while !done(iter, state)
(i, state) = next(iter, state)
@show i
end
state = start(iter)
while !done(iter, state)
(other_i, other_state) = next(iter, state)
(i, state) = next(iter, state)
@show i
end
Am I really wrong? I ask because I came across some iterators in julia's external packages without respecting this.
source
share