Skip to content

Instantly share code, notes, and snippets.

@healsjnr
Created April 14, 2016 05:08
Show Gist options
  • Save healsjnr/036154dd25a01f78c0efef680c7da7b0 to your computer and use it in GitHub Desktop.
Save healsjnr/036154dd25a01f78c0efef680c7da7b0 to your computer and use it in GitHub Desktop.
Zip with predicate
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