Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
9 lines (8 sloc) 221 Bytes
// P09 Pack consecutive duplicates of list elements into sublists.
// Recursion with "span"
def f1[T]: List[T] => List[List[T]] = {
case Nil => Nil
case h :: t =>
val (a, b) = t.span(h ==)
(h :: a) :: f1(b)
}