Skip to content

Instantly share code, notes, and snippets.

@nurkiewicz
Created February 22, 2013 15:04
Show Gist options
  • Save nurkiewicz/5014040 to your computer and use it in GitHub Desktop.
Save nurkiewicz/5014040 to your computer and use it in GitHub Desktop.
def peak(list: List[Int]): Option[Int] =
list.sliding(3).collectFirst{case(List(x, y, z)) if(y > x && y > z) => y}
def raisePeak(list: List[Int]): Option[List[Int]] =
peak(list).map(p => List(p + 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment