Skip to content

Instantly share code, notes, and snippets.

@ppiotrow
Created October 2, 2013 18:11
Show Gist options
  • Save ppiotrow/6798040 to your computer and use it in GitHub Desktop.
Save ppiotrow/6798040 to your computer and use it in GitHub Desktop.
def p12[T](list: Seq[(Int, T)]): Seq[T] = {
@tailrec
def p12inner(listInner: Seq[(Int, T)], acc: List[T]): Seq[T] = {
if (listInner.isEmpty) acc
else
p12inner(listInner.tail, acc ::: List.fill(listInner.head._1)(listInner.head._2))
}
p12inner(list, List())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment