in reply to Re: Allocation of anonymous arrays (ref addr)
in thread Allocation of anonymous arrays

fw() for 1 .. 10; sub fw { my %uniq; for my $ix ( 0 .. 100 ){ for my $key ( wf() ){ my $count = $uniq{$key}++; if( $count > 1 ){ my $keycount = keys %uniq; my $buckets = %uniq; print "started repeating at iteration $ix after only $ +keycount in $buckets buckets \n"; return; } } } } sub wf { my %f; $f{ [] } = [0]; $f{ [] } = [1]; $f{ [] } = [2]; $f{ [] } = [3]; return keys %f; } __END__ started repeating at iteration 8 after only 26 in 20/32 buckets started repeating at iteration 4 after only 14 in 13/32 buckets started repeating at iteration 5 after only 17 in 14/32 buckets started repeating at iteration 5 after only 17 in 13/32 buckets started repeating at iteration 5 after only 19 in 15/32 buckets started repeating at iteration 5 after only 18 in 16/32 buckets started repeating at iteration 6 after only 18 in 16/32 buckets started repeating at iteration 7 after only 20 in 15/32 buckets started repeating at iteration 6 after only 18 in 14/32 buckets started repeating at iteration 7 after only 26 in 21/32 buckets

Replies are listed 'Best First'.
Re^3: Allocation of anonymous arrays (ref addr repeats)
by Discipulus (Canon) on Feb 07, 2014 at 11:36 UTC
    sorry for my ignorance Anonymous, but what are you demonstrating here? can you explain your code?

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      sorry for my ignorance Anonymous, but what are you demonstrating here? can you explain your code?

      Um, what do you think I'm demonstrating? What do you understand about the code?

      :)

      I think I'm demonstrating that reference adresses get reused rather quickly ...

      Is this relevant for the OP? I can't say :|

      If all that happens is  my %f = ([],[]); my %g = reverse %f; then both %f and %g will have unique key-value pairs guaranteed

      If at some point other references are added as keys then collisions will happen