summaryrefslogtreecommitdiff
path: root/do/reverse
diff options
context:
space:
mode:
Diffstat (limited to 'do/reverse')
-rw-r--r--do/reverse19
1 files changed, 19 insertions, 0 deletions
diff --git a/do/reverse b/do/reverse
new file mode 100644
index 0000000000..32598ab7d1
--- /dev/null
+++ b/do/reverse
@@ -0,0 +1,19 @@
+int
+do_reverse(arglast)
+int *arglast;
+{
+ STR **st = stack->ary_array;
+ register STR **up = &st[arglast[1]];
+ register STR **down = &st[arglast[2]];
+ register int i = arglast[2] - arglast[1];
+
+ while (i-- > 0) {
+ *up++ = *down;
+ if (i-- > 0)
+ *down-- = *up;
+ }
+ i = arglast[2] - arglast[1];
+ Move(down+1,up,i/2,STR*);
+ return arglast[2] - 1;
+}
+