Modify recursiveLinearSearch with a closure.