#include #include forall( [N] ) void print1d_cstyle( array(float, N) & c ); forall( [N], C & | ar( C, float, N ) ) void print1d( C & c ); forall( [N] ) void print1d_cstyle( array(float, N) & c ) { for ( i; N ) { sout | c[i] | nonl; } sout | nl; } forall( [N], C & | ar( C, float, N ) ) void print1d( C & c ) { for( i; N ) { sout | c[i] | nonl; } sout | nl; } void fill( array(float, 5, 7) & a ) { for ( i; (ptrdiff_t) 5 ) { for ( j; 7 ) { a[i,j] = 1.0 * i + 0.1 * j; sout | a[[i,j]] | nonl; } sout | nl; } sout | nl; } int main() { array( float, 5, 7 ) a; fill(a); /* 0.0 0.1 0.2 0.3 0.4 0.5 0.6 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 2.1 2.2 2.3 2.4 2.5 2.6 3.0 3.1 3.2 3.3 3.4 3.5 3.6 4.0 4.1 4.2 4.3 4.4 4.5 4.6 */ print1d_cstyle( a[ 2 ] ); // 2.0 2.1 2.2 2.3 2.4 2.5 2.6 print1d( a[ 2 ] ); // 2.0 2.1 2.2 2.3 2.4 2.5 2.6 print1d( a[ 2, all ] ); // 2.0 2.1 2.2 2.3 2.4 2.5 2.6 print1d( a[ all, 3 ] ); // 0.3 1.3 2.3 3.3 4.3 print1d_cstyle( a[ 2, all ] ); #ifdef SHOW_ERROR_1 print1d_cstyle( a[ all, 2 ] ); // bad #endif }