The cartesian function inside List::Gen seems to be limited by the unsigned 32-bit upper limit on my 64-bit Windows OS:
use strict;
use warnings;
use List::Gen '*';
use 5.010;
use bigint; # This didn't help either
say $List::Gen::VERSION; # 0.80
my $diameters = range( 1, 175 );
my @five_in_a_row = ( $diameters ) x 5;
my $combinations = cartesian { \@_ } @five_in_a_row;
say 0+@$combinations; # Should be 175**5 == 164_130_859_375
# prints -1+2**31 == 2_147_483_647
Is there any way to overcome this limitation? My Perl build details are below.
> perl -vThis is perl 5, version 12, subversion 3 (v5.12.3) built for
MSWin32-x64-multi-thread (with 9 registered patches, see perl -V for
more detail)
At some point, the tied interface to generators will always be limited, due to perl fitting array indicies into 32 or 64 bit integers. Beyond that range, you can use the object oriented interface to generators, which is not limited to
2**31-1and is much faster than then tied interface.and to get an element:
or
And I will add auto-detected 64-bit limits to the list of improvements to make before the next release.