-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
julia> collect(Iterators.Stateful(2x for x in 1:3))
2-element Vector{Int64}:
2
4
The input has 3 elements, I would therefore expect the output also to have 3 elements, but there are only 2.
On the other hand, the problem disappears if
-
we remove the generator
collect(Iterators.Stateful(1:3)) 3-element Vector{Int64}: 1 2 3 -
we use
iteratedirectlyjulia> s = Iterators.Stateful(2x for x in 1:3); julia> iterate(s) (2, nothing) julia> iterate(s, ans[2]) (4, nothing) julia> iterate(s, ans[2]) (6, nothing) julia> iterate(s, ans[2]) julia>
versioninfo
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, ivybridge)
julia>
The problem also appears in julia 1.3.1, but it seems to be behaving as expected in 1.0.
Edit:
My 1.3.1 trial was in an online REPL (https://replit.com/languages/julia) which claims to be 1.3.1 but versioninfo() shows 1.4.1
julia version 1.3.1
versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, haswell)
collect(Iterators.Stateful(2x for x in 1:3))
2-element Array{Int64,1}:
2
4
Metadata
Metadata
Assignees
Labels
No labels