# Ruby, 83 f=->a{a.each_cons(3).map{|x|((x[0]<=>x[1])+(x[2]<=>x[1])).abs==2?x[1]:nil}.compact} Uses the `<=>` "spaceship" operator, which I really like. (It returns 1 if the first thing is greater than the second, -1 if it's less, and 0 if equal. Therefore, if they add to -2 or 2, that means the middle is an extreme.) Also, I like `each_cons` which selects each `n` groups of consecutive elements in an array. And, `compact` removes `nil` values, which is useful.