Closed
Description
Tl;Dr:
Add
Base.keys(gen::Base.Generator) = Base.keys(gen.iter)
to Base.
Partially related to my comment in #34368 (comment) regarding the support of traits on generators.
Currently there is no way to use find* on generators. Reason is that there is no keys function:
julia> findmax(abs(x-1) for x in [1,5,2,9])
ERROR: MethodError: no method matching keys(::Base.Generator{Array{Int64,1},var"#97#98"})
But since generators are said to be the lazy variant of map
and map
preserves the indices it would be good to define that missing keys
method.
That would allow for some very generic findmax(iter)
and argmax(iter)
as arbitrary lazy maps are allowed while maintaining good performance and low memory footprint.
Edit: adding the missing find* and arg* with custom transform functions would be appreciated aswell to allow for the convenient do-block notation.
Metadata
Metadata
Assignees
Labels
No labels