Skip to content

Instantly share code, notes, and snippets.

@kastoestoramadus
Last active August 29, 2015 14:02
Show Gist options
  • Save kastoestoramadus/3c7790882fbd43fc4ea8 to your computer and use it in GitHub Desktop.
Save kastoestoramadus/3c7790882fbd43fc4ea8 to your computer and use it in GitHub Desktop.
package pl.japila.scalania.s99
object S99_P02 {
def penultimate[T](ts: Seq[T]): T = ts match {
case a :: b :: Nil => Some(a)
case a:: tail => None
case _ => penultimate(ts.tail)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment