Implement the Sized trait to allow len() function.
Implement the __iter__ method and struct _NDArrayIter to iterate over the items in an ndarray.
fn main() raises:
get(4, 4)
fn get(m:Int, n:Int) raises:
var raw = List[Int32]()
for _i in range(m*n):
raw.append(random.randn_float64() * 10)
var Ac = NDArray(data=raw, shape=List[Int](m,n), order="C")
for i in Ac:
print(i, end=" ")
print(Ac)
print(str("=") * 50)
Implement the
Sized
trait to allowlen()
function. Implement the__iter__
method and struct_NDArrayIter
to iterate over the items in an ndarray.Output: