Created
April 27, 2017 04:56
-
-
Save fahadsiddiqui/aa596d917cb3ecf9632069b19134dc82 to your computer and use it in GitHub Desktop.
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 foo(l: List[Any]): List[Int] = { | |
l flatMap { | |
case e: Int => List(e) | |
case f: List[Any] => foo(f) | |
} | |
} | |
foo(List(1, List(1, 3, List(1, 7, List(3, 5, 7))))) // results List(1, 1, 3, 1, 7, 3, 5, 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment