concatenate method

List concatenate(
  1. List list1,
  2. dynamic list2, {
  3. int axis = 0,
})

Concatenation refers to joining. This function is used to join two arrays of the same shape along a specified axis. The function takes the following parameters note: Axis along which arrays have to be joined. Default is 0 note 2: concatenation of n number of arrays comming soon.....

Implementation

List concatenate(List list1, list2, {int axis = 0}) {
  if (axis > 1 || axis < 0) {
    throw ('axis only support 0 and 1');
  }
  var shape1 = shape(list1);
  var shape2 = shape(list2);
  if (axis == 1) {
    if (shape1[0] == shape2[0]) {
      var temp = fill(shape1[0], shape1[1] + shape2[1], null);
      for (var i = 0; i < shape1[0]; i++) {
        temp[i] = list1[i] + list2[i];
      }
      return temp;
    } else {
      throw ('all the input array dimensions for the concatenation axis must match exactly');
    }
  } else {
    if (shape1[1] == shape2[1]) {
      return list1 + list2;
    } else {
      throw new Exception(
          'all the input array dimensions for the concatenation axis must match exactly');
    }
  }
}