# $Id: hash.parrot,v 1.0 2002/08/20 11:14:00 dada Exp $ # http://dada.perl.it/shootout/ set I1, P0[1] new P1, .PerlHash # new P2, .PerlInt set I0, 1 BUILD: bsr DEC2HEX # set P2, I0 # set P1[S0], P2 set P1[S0], I0 inc I0 le I0, I1, BUILD set I0, 0 COUNT: set S0, I1 # print "GET hash(" # print S0 # print ")=" # set P2, P1[S0] # typeof I2, P2 # typeof S2, P2 # print S2 set I2, P1[S0] unless I2, NEXT # eq I2, .PerlUndef, NEXT # print " ++" inc I0 NEXT: # print "\n" dec I1 if I1, COUNT print I0 print "\n" end DEC2HEX: set S0, "" set I10, I0 DEC2HEX_START: mod I11, I10, 16 lt I11, 10, DEC2HEX_N eq I11, 15, DEC2HEX_F eq I11, 14, DEC2HEX_E eq I11, 13, DEC2HEX_D eq I11, 12, DEC2HEX_C eq I11, 11, DEC2HEX_B eq I11, 10, DEC2HEX_A DEC2HEX_N: set S1, I11 concat S0, S1, S0 branch DEC2HEX_NEXT DEC2HEX_A: concat S0, "a", S0 branch DEC2HEX_NEXT DEC2HEX_B: concat S0, "b", S0 branch DEC2HEX_NEXT DEC2HEX_C: concat S0, "c", S0 branch DEC2HEX_NEXT DEC2HEX_D: concat S0, "d", S0 branch DEC2HEX_NEXT DEC2HEX_E: concat S0, "e", S0 branch DEC2HEX_NEXT DEC2HEX_F: concat S0, "f", S0 DEC2HEX_NEXT: div I10, I10, 16 if I10, DEC2HEX_START ret