BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
#! perl -w use strict; local ($,=" - ", $\="\n"); use Quantum::Superpositions; sub min { eigenstates( any(@_) <= all(@_) ) } sub max { eigenstates( any(@_) >= all(@_) ) } my @array = qw/ 10 15 20 10 7 4 /; my $t1 = all(); print $t1; my $t2 = max(@array); print $t2; print max(@array), ($t1 = max(@array)), $t2; __DATA__ # Ouput C:\test>180278 all() 1 20 - 1 - 1
Can someone explain to me why the max function works when called in the final print statement, but fails in every attempt I make to assign its return to a variable?
I thought this might be to do with the variable needing to be blessed, hence the seemingly dumb attempt to ensure this in when I declare $t1.
sub max() appears to be doing the right thing (as you'd expect as it is copied from the Q::SP pod, but it's not so useful if I cannot assign it to anything.
Is this a "context" problem?
Thanks.
Edit by dws to expand title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem using Q::SP's
by Joost (Canon) on Jul 10, 2002 at 15:09 UTC | |
by BrowserUk (Patriarch) on Jul 10, 2002 at 15:43 UTC | |
by RMGir (Prior) on Jul 10, 2002 at 16:03 UTC | |
|
Re: Problem using Q::SP's
by RMGir (Prior) on Jul 10, 2002 at 15:10 UTC |