Skip to content

Instantly share code, notes, and snippets.

@ajozwik
Last active December 25, 2015 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajozwik/7011462 to your computer and use it in GitHub Desktop.
Save ajozwik/7011462 to your computer and use it in GitHub Desktop.
def p14[T](ts: Seq[T]): Seq[T] = p15(2,ts)
def p15[T](n:Int,ts: Seq[T]): Seq[T] = {
def p15( ts: Seq[T], acc: Seq[T]): Seq[T] = ts match {
case Nil => acc.reverse
case h :: t => p15(t, Seq.fill(n)(h) ++ acc)
}
p15( ts, Nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment