On Julia v0.6.4 the following worked, but no longer on v0.7, v1.0.x and v1.1.0:
a = rand(3)
findmax( a[j] for j = 1:3 )
results in
ERROR: MethodError: no method matching keys(::Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##13#14"))})
Closest candidates are:
keys(::Cmd) at process.jl:940
keys(::Core.SimpleVector) at essentials.jl:570
keys(::Tuple) at tuple.jl:46
...
Stacktrace:
[1] pairs(::Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##13#14"))}) at ./abstractdict.jl:132
[2] _findmax(::Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##13#14"))}, ::Colon) at ./array.jl:2052
[3] findmax(::Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##13#14"))}) at ./array.jl:2049
[4] top-level scope at none:0
Bug or intended behaviour? What makes me wonder whether it is a bug is that replacing findmax
with maximum
works as expected.
But maybe it isn’t a bug then I suppose the issue is that I’m passing a generator instead of a collection. How do I convert a generator into a collection? I am not sure what to look for in the documentation…