Strage behaviour of Stateful iterator:
Although
julia> for a in Iterators.Stateful([1,2,3])
print(a)
end
123
works as it should,
With list comprehension it fails to iterate over last element
julia> [a for a in Iterators.Stateful([1,2,3])]
2-element Array{Int64,1}:
1
2
julia> [a for a in Iterators.Stateful([1])]
ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at index [1]
tried on Julia 1.3.1, Julia 1.4.0 and Julia 1.4.1.
More details in https://discourse.julialang.org/t/strange-behavior-with-list-comprehensions-using-iterators-stateful/29715