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

Allow searching for subvectors of vectors in contains #24303

Open
Keno opened this issue Oct 23, 2017 · 3 comments
Open

Allow searching for subvectors of vectors in contains #24303

Keno opened this issue Oct 23, 2017 · 3 comments
Labels
search & find The find* family of functions

Comments

@Keno
Copy link
Member

Keno commented Oct 23, 2017

I'd have expected the following to work:

julia> contains(UInt8[1, 2, 3], UInt8[2, 3])
ERROR: MethodError: no method matching contains(::Array{UInt8,1}, ::Array{UInt8,1})
Closest candidates are:
  contains(::Function, ::Any, ::Any) at reduce.jl:664

having the same meaning as it does for strings.

@nalimilan nalimilan added the search & find The find* family of functions label Oct 24, 2017
@nalimilan
Copy link
Member

BTW, contains could be integrated to the find* family of functions. We could keep it as a convenience function, with a fallback to something like findfirst(sequence(needle), haystack) > 0.

@nalimilan
Copy link
Member

See also #19250 and #18028. I think we should get rid of ismatch which is quite restrictive as it only works with regular expressions, and merge it with contains. This appears to be the consensus.

@JeffBezanson
Copy link
Member

My only slight concern is that find* works with indices, and there could be cases where a sequence doesn't have indices or where it's more expensive to determine an index than to determine whether a match exists. But find* works for all current cases, so we can go ahead with switching to find*, and possibly add an issubseq that defaults to calling find(needle, haystack) > 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
search & find The find* family of functions
Projects
None yet
Development

No branches or pull requests

3 participants