Created
August 31, 2011 13:09
-
-
Save akr4/1183503 to your computer and use it in GitHub Desktop.
flatMapSublists?
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 flatMapSublists[A,B](ls: List[A])(f: (List[A]) => List[B]): List[B] = { | |
def sublists[A](ls: List[A]): List[List[A]] = { | |
ls match { | |
case Nil => List(List()) | |
case x :: xs => ls :: sublists(xs) | |
} | |
} | |
sublists(ls).flatMap(f) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment