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

_auto_declare=1;
n = integer(__argv[1]);
hash1 = Assoc_Type[Int_Type];
_for (1, 10000, 1)
{
   i = ();
   hash1[strcat ("foo_", string(i))] = i;
}

hash2 = Assoc_Type[Int_Type, 0];
loop (n)
{
   foreach (hash1) using ("keys", "values")
     {
    (k,v) = ();
    hash2[k] += v;
     }
}

vmessage ("%d %d %d %d",
      hash1["foo_1"], hash1["foo_9999"], hash2["foo_1"], hash2["foo_9999"]);