-
-
Notifications
You must be signed in to change notification settings - Fork 695
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
Make Ranges Chainable through Concatenation Operator ~ #3353
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
38b1d3b
First try
nordlow 1dd3bfb
Support consecutive chains
nordlow db59e25
Support map
nordlow 19892ff
Support FilterBidiResult
nordlow ea15bd4
Support uniq
nordlow a359666
Support chain
nordlow 007ed96
Use opBinary instead of opCat
nordlow 74f3649
Add first try at documentation
nordlow 592ffcc
Fix bug in cache unittest
nordlow 07831aa
Support splitter
nordlow 1e3ff0b
Use mixin joiner Result but comment out failing unittest
nordlow a8be293
Support choose and chooseAmong
nordlow 895d9d5
Fix failing unittest for chooseAmong
nordlow 92f0d6b
Support roundRobin
nordlow 3593280
Add unittest for radial
nordlow 6612f0b
Support take
nordlow 110213a
Support takeExactly
nordlow 6205e83
Support takeOne
nordlow 756de79
Support take
nordlow 6753e89
Assert that infinite ranges are only placed at the end of a chain
nordlow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2239,3 +2239,22 @@ if (!isNarrowString!(T[])) | |
size_t i = a.length - std.utf.strideBack(a, a.length); | ||
return decode(a, i); | ||
} | ||
|
||
/** | ||
This template shall be mixed in at the top-scope inside of the $(D Result) | ||
struct of each $(D InputRange) in order to support lazy chaining via | ||
concatenation operation as `x ~ y` instead of via $(D chain(x, y))). | ||
*/ | ||
template Chainable() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documentation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First try is done. |
||
{ | ||
import std.traits: Unqual, CommonType; | ||
import std.range: ElementType; | ||
auto opBinary(string op : "~", Range)(Range r) | ||
if (isInputRange!(Unqual!Range) && | ||
is(CommonType!(ElementType!(typeof(this)), | ||
ElementType!Range))) | ||
{ | ||
import std.range : chain; | ||
return chain(this, r); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is this not doing the mixin?
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.
Because I needed a specialized logic for flattening of the
chain
-tree as mentioned below.If this flattening is not needed we can reuse
Chainable
here, of course.If not, I guess it's better to move this tree-flattening logic to
Chainable
...aah but because Result is a Voldemort type I don't think this is possible.My plan now instead is to do something like
Is there some way to check if rhs argument r is a chain?
What do you say?
Is this in vain?