/* this actually works. 2005-11-28 */ use Array:all; use Math:all; use SimplePrint:all; inline int[+] librotate (int count, int[+] A) { if (_lt_(count, 0)) count = _add_SxS_( count, _shape_(A)[0]); offset = _modarray_( _mul_SxA_( 0, _shape_(A)), [0], count); slice_shp = _modarray_(_shape_(A), [0], count); result = with (offset <= iv <= .) { array_elem = _sel_(iv-offset, A); } modarray( A, iv, array_elem); result = with (. <= iv < slice_shp) { array_elem = _sel_(_shape_(A)-slice_shp+iv, A); } modarray( result, iv, array_elem); return(result); } inline int[.] iotaXII(int shp) { /* Index generator on scalar */ /* HELP! Needs domain check for negative shp */ res = with( . <= [i] <= .) genarray( [(shp)], i); return( res); } inline int[*] rotrBII(bool x, int[*] y) { /* Scalar rotate matrix last axis */ k = toi(x); z = librotate(-k, y); return (z); } int main() { v3=iotaXII(0); v4=rotrBII(true,v3); z=print(v3); z+=print(v4); return(z); }