mgatto has asked for the wisdom of the Perl Monks concerning the following question:
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' ) ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: List::Util can't find max in array of BigInts
by Athanasius (Archbishop) on Apr 24, 2013 at 03:06 UTC | |
by mgatto (Novice) on Apr 25, 2013 at 19:33 UTC | |
by Athanasius (Archbishop) on Apr 26, 2013 at 13:01 UTC | |
|
Re: List::Utils can't find max in array of BigInts (XS--)
by tye (Sage) on Apr 24, 2013 at 03:57 UTC | |
by salva (Canon) on Apr 24, 2013 at 07:32 UTC | |
by tye (Sage) on Apr 24, 2013 at 15:01 UTC | |
by locked_user sundialsvc4 (Abbot) on Apr 24, 2013 at 12:31 UTC | |
by mgatto (Novice) on Apr 25, 2013 at 20:09 UTC |