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

Add substrings() #229

Merged
merged 4 commits into from Aug 17, 2018
Merged

Add substrings() #229

merged 4 commits into from Aug 17, 2018

Conversation

bbayles
Copy link
Collaborator

@bbayles bbayles commented Aug 7, 2018

Re: #227, I did like the "generate all windows" thing, so here's a thing to do that.

@pylang
Copy link

pylang commented Aug 7, 2018

Neat implementation. To be clear, is the motivation to make a more efficient windowed?


Since these items are contiguous elements, the formal name would be "substring" rather than subsequence. The classic name "substring" is terribly confusing imo, but here is the distinction:

  • substring: contiguous elements "abc" -> "" "a" "b" "c" "ab" "bc" "abc" (similar to windowed)
  • subsequence: contiguous/non-contiguous "abc" -> "" "a" "b" "c" "ab" "bc" "ac" "abc" (similar to powerset)

Notice like the haskell function, subsequences include the non-contiguous element "ac".

By contrast, "substring" is altogether a bad name. In particular, the tool can be mistakenly constrained to the str type when it should work on any iterable. However, I'm not sure what other name to call this tool aside from contigious_subsequences (not great).


You may be seeking real problems to test this tool against. Consider the following:

I find it helpful to have a reverse parameter is some of these cases.

@bbayles
Copy link
Collaborator Author

bbayles commented Aug 8, 2018

Ah, Wikipedia says:

The subsequence should not be confused with substring

Which is precisely what I did. I'll rename this.

@bbayles bbayles changed the title Add subsequences() Add substrings() Aug 8, 2018
@bbayles bbayles merged commit fab501e into master Aug 17, 2018
@bbayles bbayles deleted the subseq branch August 17, 2018 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants