This is existing code, but arr is a reference to the array being looped (patterns). As a result the function is changing the values of patterns and no return is required.