% $Id: ary3.slang,v 1.0 2003/01/03 14:06:00 dada Exp $
% http://dada.perl.it/shootout/
%
% contributed by John E. Davis


define main_slow()
{
   variable n = integer (__argv[1]);
   variable x = Int_Type[n];
   variable y = Int_Type[n];
   _for (0,n-1,1)
     {
    variable i = ();
        x[i] = i + 1;
     }
   loop (1000)
     {
    i = [n-1:0:-1];
    y[i] += x[i];
     }
   
   vmessage ("%S %S", y[0], y[-1]);
}

% define main_fast ()
% {
%    variable n = integer (__argv[1]);
%    variable x = [1:n];
%    variable y = Int_Type[n];
% 
%    loop (1000)
%      y += x;
% 
%    vmessage ("%S %S", y[0], y[-1]);
% }

main_slow();