arrayComplexTruncateLast function Null safety

ArrayComplex arrayComplexTruncateLast(
  1. ArrayComplex a
)

Return a Array without the last element

Examples

var list = ArrayComplex([
  Complex(real: 3.0, imaginary: 4.0),
  Complex(real: 3.0, imaginary: 4.0) ,
  Complex(real: 3.0, imaginary: 4.0)]);

print(list.cos());

/* expected output:
ArrayComplex([Complex(real: -27.034945603074224, imaginary: -3.8511533348117775), Complex(real: -27.034945603074224, imaginary: -3.8511533348117775), Complex(real: -27.034945603074224, imaginary: -3.8511533348117775)])
*/

Implementation

ArrayComplex arrayComplexTruncateLast(ArrayComplex a) {
  var c = ArrayComplex.fixed(a.length - 1);
  for (var i = 0; i < c.length; i++) {
    c[i] = a[i];
  }
  return c;
}