Created
June 17, 2012 00:34
-
-
Save SethTisue/2942990 to your computer and use it in GitHub Desktop.
add zipWith to Iterable
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
// add zipWith to Iterable; thank you stackoverflow.com/q/3895813 | |
implicit class RichIterable[A, CC[X] <: Iterable[X]](xs: CC[A]) { | |
type Builder[C] = collection.generic.CanBuildFrom[Nothing, C, CC[C]] | |
def zipWith[B, C](ys: Iterable[B])(f: (A, B) => C)(implicit cbf: Builder[C]): CC[C] = | |
xs.zip(ys).map(f.tupled)(collection.breakOut) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment