[swift-corelibs-dev] LazySequenceType: make prefix return a lazy collection
Mark Aron Szulyovszky
mark.szulyovszky at gmail.com
Mon Jan 4 07:15:52 CST 2016
I came across hit issue while chaining filter() and prefix() on lazy
And started wondering if it would be more consistent if
lazy.filter().prefix() returned a custom
LazySequenceType<Generator.Element> instead of
That way lazy.filter().prefix() could be used to chain *pure lazy
operations*, which can be actually quite useful in some cases.
I understand that this has implications, and it would make prefix() less
consistent in terms of return type, but it would eliminate confusion like
Also, this wouldn't be a much different than how how lazy.filter() is
implemented, since it also returns a custom LazySequenceType instead of
Has this been considered before? Would there be any cases where this would
create unintended side effects?
As far as I see, it wouldn't change the meaning of prefix(), only would it
extend its usefulness.
I submitted a PR to the SwiftSequence library that demonstrates the
implementation of this:
And I'm happy to contribute to contribute it to stdlib if people find it
Thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-corelibs-dev