// $Id: hash2.ici,v 1.0 2003/01/03 11:46:00 dada Exp $ // http://dada.perl.it/shootout // // contributed by Tim Long n = argv[1] ? int(argv[1]) : 1; h1 = struct(); for (i = 0; i < 10000; ++i) h1[sprintf("foo_%d", i)] = i; h2 = struct(); for (i = 0; i < n; ++i) { forall (v, k in h1) { if (h2[k] == NULL) h2[k] = 0; h2[k] += h1[k]; } } printf("%d %d %d %d\n", h1["foo_1"], h1["foo_9999"], h2["foo_1"], h2["foo_9999"]);