SPUG: Primes

Fred Morris m3047 at inwa.net
Sat Oct 6 11:01:51 PDT 2007


Good to know!

--

Fred Morris

On Saturday 06 October 2007 04:34, John W. Krahn wrote:
> Fred Morris wrote:
> > [...]
> >     my $next_i = $i + $k;
> >     if (exists $numbers{$next_i}) {
> >         push @{$numbers{$next_i}}, $k;
> >     }
> >     else {
> >         $numbers{$next_i} = [$k];
> >     }
> 
> No need to test for key existence, perl will autovivify the array.
> 
>        my $next_i = $i + $k;
>        push @{ $numbers{ $next_i } }, $k;
> 



More information about the spug-list mailing list