Sam Stone
04/12/2022, 11:05 PMIterable<A>.zip(Iterable<B>)
version similar to Iterable.withIndex()
that returns an Iterable<Pair<A, B>>
instead of what withIndex()
returns (viz. Iterable<Pair<T, Int>
). I called it Iterable.with(Iterable): ZippingIterable
(instead of IndexingIterable
for withIndex()
). It seems like a natural corollary to withIndex()
and a common enough use case (viz. two Iterables, want to zip like zip
but want it lazy like withIndex
). Thoughts?ephemient
04/12/2022, 11:14 PMSequence
?Sam Stone
07/26/2022, 8:37 AMephemient
07/26/2022, 12:32 PMfun <T, U> Iterable<T>.with(other: Iterable<U>): Iterable<Pair<T, U
> =
this.asSequence()
.zip(other.asSequence())
.asIterable()
but there should be no need for this function and in most uses you won't need .asIterable()
in the end eitherSam Stone
07/26/2022, 11:14 PMasIterable()
?ephemient
07/27/2022, 9:46 AM.asSequence()
in the caller to adapt the things that aren't. and almost all of the iterable operations you would want to follow it up with, also exist on sequence, so there's rarely a need to use .asIterable()
to create a wrapper