Working through Project Euler, I return the result as an array of bigints, but using it as an argument for max(), map() or anything from List::Util does not work. Here's the code:
# big_factors() is my sub finding all the primes of a number. my @result = big_factors(600851475143); say max @result;
I get this error, but Google has nothing for me:
Can't call method "can" on unblessed reference at C:/Languages/Perl/perl/lib/Math/BigInt.pm line 2693.
Using Data::Dumper shows me the actual integers, though. I'm at a loss: how can I operate on arrays of Bigints in Perl?
Edit 1: I'm using Strawberry Perl 5.14.2 (Windows, naturally).
Edit 2: Some interesting differences in output methods:
say "@result"; ARRAY(0x3faefc) 71 839 1471 6857 say $result[1]->numify; 71This is indeed true.
print Dumper \@result;$VAR1 = [ [], bless( { 'value' => [ 71 ], 'sign' => '+' }, 'Math::BigInt' ), bless( { 'value' => [ 839 ], 'sign' => '+' }, 'Math::BigInt' ), bless( { 'value' => [ 1471 ], 'sign' => '+' }, 'Math::BigInt' ), bless( { 'value' => [ 6857 ], 'sign' => '+' }, 'Math::BigInt' ) ];
In reply to List::Utils can't find max in array of BigInts by mgatto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |