Last active
August 28, 2019 08:44
-
-
Save idarlington/e7ea83be5febcee247ce5f8a5586940e to your computer and use it in GitHub Desktop.
Scala list intersection
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 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