function concat () {
  const arrays = Array.prototype.slice.call(arguments, 0, -1)
  const concatDim = Array.prototype.slice.call(arguments, -1)

  if (arrays.length === 1) {
    return arrays[0]
  }
  if (arrays.length > 1) {
    return arrays.slice(1).reduce(function (A, B) { return concatRecursive(A, B, concatDim, 0) }, arrays[0])
  } else {
    throw new Error('Wrong number of arguments in function concat')
  }
}
Concatenates many arrays in the specified direction
@param {...Array} arrays All the arrays to concatenate
@param {number} concatDim The dimension on which to concatenate (zero-based)
@returns {Array}