RosettaCodeData/Task/Forward-difference/PL-I/forward-difference.pli

22 lines
547 B
Plaintext

/* Forward differences. */ /* 23 April 2010 */
differences: procedure options (main);
declare a(10) fixed(10) static initial
(7, 3, 9, 250, 300, 4, 68, 72, 154, 601);
declare (i, j, m, n, t, u) fixed binary;
m = hbound(a,1);
get (n); if n > m then signal error;
put skip edit (a) (F(7));
do i = 1 to n;
t = a(i);
do j = i+1 to m;
u = a(j);
a(j) = a(j) - t;
t = u;
end;
put skip edit (a) (F(7));
end;
put skip edit ((a(i) do i = n+1 to m)) (F(9));
end differences;