Description
It might be useful to define curried version of iterator transforms such as Iterators.map(f) = x -> Iterators.map(f, x)
(after #34352) and Iterators.filter(f) = x -> Iterators.filter(f, x)
(ref #33027, #24990 (comment)). However, since the eager counter part map(f)
is currently defined as f()
, it may confuse users when the difference between map(f)
and Iterators.map(f)
are more than laziness.
Can we remove map(f)
at some point? (I think whether or not it is desirable to do this within Julia 1.x is up to core devs.) I think it makes sense to also remove foreach(f)
when removing map(f)
for consistency.
map(f)
was added by @stevengj in #17318. The reasoning was that it is better to be consistent with f.()
. I agree that considering f.()
as a special case of f.(args...)
makes sense for broadcasting; i.e., the output dimension of broadcasting is reduce(max, ndims_of_arguments)
when ndims_of_arguments
is not empty. Since ndims
is always a non-negative integer, it is reasonable to use the identity element of max
on non-negative integers which is 0
, when there is no argument. However, this argument relies on that the "ndims
" of the output is flexibly determined (i.e., using the largest ndims
) in broadcasting. As this is not the case in map
, I think it makes less sense to define map(f)
as f()
. OTOH, I think curried map
is a useful definition.
foreach(f)
was added by @JeffBezanson in #13774. It seems there was no discussion for adding foreach(f)
.