Is there a good reason that there is no single-argument version of filter that returns a filter-function? I.e. why is the following (or something similar) not in Base
filter(f::Function) = Base.Fix1(filter, f)
?
This would be in line with the existence of <(x) = (y -> y < x) or occursin(haystack) = (needle -> (occusin(needle, haystack))) and very useful for data processing pipelines using |>.
I found this thread which disusses alternatives, but gives no reason why this shouldn’t exist in Base.
julia> f() = 5
f (generic function with 1 method)
julia> map(f)
5
This behavior seems to violate any meaningful notion of mapping a collection[s] to another, and it’s not in the docstring. Under what circumstance is this useful?
For comparison:
>>> def f():
... return 5
...
>>> list(map(f))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: map() must have at least two arguments.