Multidimensional arrays
Multidimensional arrays can be defined as:
In Sidef, we have the Array.wise_op()
method, which takes two arbitrary nested arrays and an operator, folding each element (entrywise) with the provided operator, which is also available as a ~Wop b
:
Alternatively:
Scalar operations:
This methods are provided by Array.scalar_op()
, which, just like Array.wise_op()
, also supports arbitrary nested arrays:
...which is equivalent with:
Iteration over 2D arrays
The extended for-in
loop provides support for iterating over a 2D-array, which is useful in combination with the cross and zip metaoperators:
This is equivalent with:
and outputs:
Last updated
Was this helpful?