Created
April 14, 2016 05:08
-
-
Save healsjnr/036154dd25a01f78c0efef680c7da7b0 to your computer and use it in GitHub Desktop.
Zip with predicate
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
def zipWithPredicate[A,B](predicate: (A, B) => Boolean)(listA: Seq[A], listB: Seq[B]): Seq[(A, B)] = { | |
listA.flatMap(a => listB.find(b => predicate(a, b)).map(b => (a, b))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment