Simplify the looking up in array component of the chapter six example in Scala