-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Curried versions of endswith and startswith #33193
Comments
Having a long list of functions where the first argument is considered special seems bad to me. Instead, just like with vectorized function we should IMO focus on syntax that tries to handle all of this in one fell swoop (#24990). Anything else will just be a neverending debate of what functions should implement this special handling and since Base code is not special, this will also seep out to the package ecosystem. We should learn from the |
The criteria we agreed to when starting with that currying was:
These criteria are clearly met by
For |
#24990 is very high-level and new feature oriented. Not quite done yet. One could simply generate a lot of those binding (currently defined in https://github.com/JuliaLang/julia/blob/v1.2.0/base/operators.jl with a There will be however some corner cases with builtins functions such as @test_throws ErrorException Base.:(===)(t) = Base.Fix2(:(===),t)
@test_throws ErrorException Base.isa(t) = Base.Fix2(isa,t)
@test_throws ErrorException Base.:(<:)(t) = Base.Fix2(:(<:),t) |
If we did #35031 |
I retract my comment at #33193 (comment), these specific set of functions do seem to fit the pattern where this would make sense. |
This seems decided: |
Will create one. |
I know this issue is closed and I don't mean to reopen it, but just a quick comment: Works:
Doesn't:
Is it because it violates the criteria for currying in this case? |
It doesn't work because you're trying to logically connect ( |
I see. Thanks! Is there another operator, like a pipe, to connect two objects of type |
In the spirit of #30915 I was wondering whether a PR for adding single-argument versions of
endswith
,startswith
, andoccursin
that can be used as follows in functions likefilter
would be appreciated.filter(endswith(".jl"), readdir())
I feel that I have definitely typed
x->endswith(x, ".jl")
far too often :)The text was updated successfully, but these errors were encountered: