Array.fromValue constructor

Array.fromValue(
  1. double val, {
  2. required Tuple2<int, int> shape,
})

Implementation

factory Array.fromValue(double val, {required Tuple2<int, int> shape}) {
  var m = shape.item1;
  var n = shape.item2;

  var values = [
    for (var _ in range(end: m)) [for (var _ in range(end: n)) val]
  ];

  return Array(values: values, shape: shape);
}