Can anyone please point me to overview of using (maybe different kinds) of map/reduce/filter functions in Julia (and it’s standard packages)?
Here is is what I’m missing now: I want any(map(x -> x > 0, big_rand_array)) to lazy evaluate without computing on all elements, yet it appears to allocates big resulting array of map and only then passes it to any.
(this is “first steps” question)
Thank you very much,
Many of these reduction functions can take a function as the first argument: any(>(0), randn(2)) ought to be efficient. There is a lazy map, but here you may as well combine them: any(f, Iterators.map(g, xs)) == any(f∘g, xs).
Oh I forgot which version, again, sorry, it’s in 1.6 then. It is however identical to writing the generator:
julia> Iterators.map(sqrt, 1:10)
Base.Generator{UnitRange{Int64}, typeof(sqrt)}(sqrt, 1:10)
julia> (sqrt(x) for x in 1:10)
Base.Generator{UnitRange{Int64}, typeof(sqrt)}(sqrt, 1:10)