Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
def decode[A](xs: List[(Int, A)]) : Seq[A] = xs match {
case Nil => Nil
case (times, code) :: xs => (for (i <- 1 to times) yield code) ::: decode(xs)
}
// you may also replace
// (for (i <- 1 to times) yield code)
// with
// Seq.fill(3)(code)
// so you will get
// case (times, code) :: xs => Seq.fill(times)(code) ::: decode(xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.