Skip to content
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 #35052

Merged
merged 3 commits into from
Mar 11, 2020

Conversation

carstenbauer
Copy link
Member

@carstenbauer carstenbauer commented Mar 9, 2020

See discussion in #33193.

This PR adds single-argument versions endswith(s) and startswith(s) that return functions semantically equivalent to x->endswith(x,s) and x->startswith(x,s), respectively.

Example use case: filter(endswith(".toml"), readdir())

Closes #33193.

Copy link
Member

@fredrikekre fredrikekre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like just two test cases would cover everything?

@carstenbauer
Copy link
Member Author

Seems like just two test cases would cover everything?

I started out with a definition of the curried versions including ::AbstractString annotations in which case Char support was lost. With these tests I want to make sure that whatever the definition of these curried variants is/will be in the future they should accept every type that the parent methods can handle.

In any case, the extra tests certainly don't hurt, do they?

@StefanKarpinski
Copy link
Sponsor Member

In any case, the extra tests certainly don't hurt, do they?

They don't in this case since they're fast and cheap to do but they will get run a lot.

@carstenbauer
Copy link
Member Author

They don't in this case since they're fast and cheap to do but they will get run a lot.

Makes sense. I'll leave them as they are then unless someone objects.

@fredrikekre fredrikekre added needs compat annotation Add !!! compat "Julia x.y" to the docstring needs news A NEWS entry is required for this change strings "Strings!" labels Mar 11, 2020
@carstenbauer
Copy link
Member Author

carstenbauer commented Mar 11, 2020

I've added a NEWS.md entry and compat annotations. (I also rebased onto master.)

@rfourquet rfourquet removed needs compat annotation Add !!! compat "Julia x.y" to the docstring needs news A NEWS entry is required for this change labels Mar 11, 2020
@JeffBezanson JeffBezanson merged commit 0a43c0f into JuliaLang:master Mar 11, 2020
@carstenbauer carstenbauer deleted the cb/curried branch March 11, 2020 21:52
ravibitsgoa pushed a commit to ravibitsgoa/julia that referenced this pull request Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Curried versions of endswith and startswith
5 participants