-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Needed: contains/issubstr/issubseq for (::String, ::String) #4153
Comments
I'm ok with |
Related #2703. |
This breaks down for loosely-typed containers; |
@JeffBezanson, are you against making Strings a special case in Julia? You also suggested |
That's why |
So |
Arguably contains should maybe not even default to that but only be used for substructure containment: is a string a substring of another? Is a set a subset of another? Is one sequence a subsequence of another. |
+1 to differentiate between substructure and element containment On Tue, Aug 27, 2013 at 4:41 PM, Stefan Karpinski
|
Sounds good to me. |
For deprecation, we can, for now, have methods where e.g. |
That's fine; I think the flipped argument order is a more serious problem. |
I'm unclear on what the flipped argument order problem is. Why is it a problem that |
There are various functions that look for something in something else ( |
These are collection, pattern: |
Decision: deprecate |
And let's not get started on |
@StefanKarpinski |
Ah good point. We should replace as many of these as we can with |
As suggested in #2890 and #2574, it would be nice to have a simple predicate for testing when a string contains a substring (or when a substring is part of a string).
contains
seems the most relevant, but has been shot down twice supposedly because it's inconsistent withcontains(collection, elem)
.issubstr
orissubstring
is a possibilityissubseq
has been suggested, and could also be used for vectorssubstr in str
, ifin
becomes an infix operator and/or we're willing to overload it like thisMy personal preference is to just use
contains
--it's the most understandable and easy to find, even if it doesn't have exactly the same meaning ascontains(collection, elem)
. ( Edit:substring in str
is also quite nice.)But either way, it would be nice to have a simple predicate. Having to write
substring(somestring, shortstring) != 0:-1
is ugly.What are people's preferences/suggestions?
The text was updated successfully, but these errors were encountered: