src/function/matrix/concat.js
function _concat (a, b, concatDim, dim) {
  if (dim < concatDim) {
    // recurse into next dimension
    if (a.length !== b.length) {
      throw new DimensionError(a.length, b.length)
    }

    const c = []
    for (let i = 0; i < a.length; i++) {
      c[i] = _concat(a[i], b[i], concatDim, dim + 1)
    }
    return c
  } else {
    // concatenate this dimension
    return a.concat(b)
  }
}
function _concat (a, b, concatDim, dim) {
  if (dim < concatDim) {
    // recurse into next dimension
    if (a.length !== b.length) {
      throw new DimensionError(a.length, b.length)
    }

    const c = []
    for (let i = 0; i < a.length; i++) {
      c[i] = _concat(a[i], b[i], concatDim, dim + 1)
    }
    return c
  } else {
    // concatenate this dimension
    return a.concat(b)
  }
}
function _concat ( a , b , concatDim , dim ) { if ( dim < concatDim ) { // recurse into next dimension if ( a . length !== b . length ) { throw new DimensionError ( a . length , b . length ) } const c = [ ] for ( let i = 0 ; i < a . length ; i ++ ) { c [ i ] = _concat ( a [ i ] , b [ i ] , concatDim , dim + 1 ) } return c } else { // concatenate this dimension return a . concat ( b ) } }
Recursively concatenate two matrices.
The contents of the matrices is not cloned.
@param {Array} a             Multi dimensional array
@param {Array} b             Multi dimensional array
@param {number} concatDim    The dimension on which to concatenate (zero-based)
@param {number} dim          The current dim (zero-based)
@return {Array} c            The concatenated matrix
@private
Recursively concatenate two matrices . The contents of the matrices is not cloned .