diff scripts/general/shift.m @ 7411:83a8781b529d

[project @ 2008-01-22 21:52:25 by jwe]
author jwe
date Tue, 22 Jan 2008 21:52:26 +0000
parents a730e47fda4d
children eb63fbe60fab
line wrap: on
line diff
--- a/scripts/general/shift.m
+++ b/scripts/general/shift.m
@@ -80,5 +80,23 @@
   endif
   y = x(idx{:});
 
+endfunction
 
-endfunction
+%!test
+%! a = [1, 2, 3];
+%! b = [4, 5, 6];
+%! c = [7, 8, 9];
+%! 
+%! r = [a, b, c];
+%! m = [a; b; c];
+%! 
+%! assert((shift (r, 3) == [c, a, b]
+%! && shift (r, -6) == [c, a, b]
+%! && shift (r, -3) == [b, c, a]
+%! && shift (m, 1) == [c; a; b]
+%! && shift (m, -2) == [c; a; b]));
+
+%!error shift ();
+
+%!error shift (1, 2, 3, 4);
+