Fix concat

The concat function is a destructive function that modifies the first array passed to it, which does not seem to be expected. The behavior is documented in bug #21171. This pull request fixes that behavior.