I have a very large List[A]
and a function f: List[A] => List[B]
. I would like to split my original list into sub-lists with a maximum size, apply the function to each sublist in turn and then unsplit the result into one big List[B]
. This pretty easy:
def split[T](l : List[T], max : Int) : List[List[T]] = //TODO
def unsplit[T](l : List[List[T]]) : List[T] = //TODO
def apply[A, B](l : List[A], f : List[A] => List[B], max : Int) : List[B] = {
unsplit(split(l, max).map(f(_)))
}
I was wondering whether scalaz supplied standard stuff to do this out of the box? In particular the apply
method?