int[*] psel( int[.] idx, int[*] array) \ { \ new_shape = _drop_SxV_( _sel_( [0], _shape_(idx)), _shape_(array)); \ res = with( . <= iv <= .) { \ new_idx = _cat_VxV_( idx, iv); \ } genarray( new_shape, _sel_(new_idx, array)); \ return( res); \ } int[*] FromArrayOnAxis(int[*] i, int ax, int[*] y) { frameshape = _take_SxV_(ax,_shape_(y)); z = with (. <= iv <= .) { cell = psel(iv, y); } genarray(frameshape, FromArray(i,cell)); return(z); } int[*] FromArray(int[*] i, int[*] y) { shpi = _shape_(i); cellshape = _drop_SxV_(1,_shape_(y)); typicalcell = with (. <= iv <= .) genarray(cellshape, 0,0); /* $OTFILL for 0 */ z = with (. <= iv <= .) { thisi = _sel_(iv,i); item = psel([thisi], y); } genarray(shpi, item, typicalcell); return(z); } int main() { y = with (. <= [i,j,k] <= . ) genarray( [5,4,3],_add_SxS_(100,i)); k = _reshape_([2,3,4], [2,1,0, 2,1,0, 2,1,0, 2,1,0, 2,1,0, 2,1,0, 2,1,0, 2,1,0]); z2 = FromArrayOnAxis(k,2,y); res = _sel_( [0,0,0,0], z2); return( res); }