Generalization of code

Code generalized/"vectorized"