generalized to arbitrary operations (unary, binary, ternary, etc.)