Skip to content

Instantly share code, notes, and snippets.

@idarlington
Last active August 28, 2019 08:44
Show Gist options
  • Save idarlington/e7ea83be5febcee247ce5f8a5586940e to your computer and use it in GitHub Desktop.
Save idarlington/e7ea83be5febcee247ce5f8a5586940e to your computer and use it in GitHub Desktop.
Scala list intersection
def intersect(first: List[Int], second: List[Int]): Seq[Int] = {
val result = for {
i <- first
j <- second
if i == j
} yield i
result.toSet.toSeq
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment