-
Notifications
You must be signed in to change notification settings - Fork 174
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
Implement starts_with and ends_with functions #384
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep this is a simple but useful one to have. Implementation and spec look good to me.
The Python versions of these functions also support some optional arguments (but I guess they are redundant since the same thing can be achieved with slicing):
Would there be any interest to have these functions also (or only) as operators? The Python functions are methods of the string class which makes the logic flow nicer:
In Fortran this could become Julia also has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful addition, thank you!
👍 from me for the custom operators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good. I think I needed these in fpm
. I use these in Python and also I had to implement in C++ for LFortran. So they are very useful.
Thanks everybody for the feedback. With four approvals I'll go ahead and merge. |
This patch implements a simple function to check whether a string starts or ends with a substring, which is a special variant of the intrinsic
index
. A similarends_with
function is currently used in thefpm_strings
module.