-
Notifications
You must be signed in to change notification settings - Fork 29
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 Source.interleaveAll combinator #13
Conversation
96ec633
to
895ba96
Compare
* scala> val res0: List[Int] = List(1, 2, 10, 20, 100, 200, 3, 4, 30) | ||
* }}} | ||
*/ | ||
def interleaveAll[U >: T](others: Seq[Source[U]], segmentSize: Int = 1, eagerComplete: Boolean = false)(using |
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.
since none of the sources is special, maybe this shoul dbe a method on Source
- Source.interlaveAll
?
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.
One downside is that this would require us to handle the case of an empty list - but then I think we just return a done source.
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.
Good point with moving it to Source
. As for the empty list - we can either return a done source as you suggest, or change the signature of interleaveAll
so that it enforces at least two sources (since one source would be a special case as well, where we just return the argument), e.g.
def interleaveAll[T](first: Source[T], second: Source[T], rest: Source[T]*)(segmentSize: Int, eagerComplete: Boolean)
The downside of the latter approach would be making the API inconsistent between interleave
and interleaveAll
. WDYT?
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.
I don't think there's an inconsistency, interleave
acts on two sources using the more convenient dot-notation, the ...All
variant takes an arbitrary list. The first
/ second
approach would be good, but then it enforces static structure - won't work if you have a dynamically-defined list of sources.
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.
One suggestion, otherwise ok :)
No description provided.