Daniel Ruoso wrote:

But even to compare two hands it gets weird...

my @a = 1|11, 9, 1|11;
my @b = 6,9,6;
my $pa = [+] @a;
my $pb = [+] @b;
if ($pa <= 21 && $pb <= 21) {
   if ($pa > $pb) {
        # B0RK3D
   }
}

That happens because $pa and $pb are a singular value, and that's how
junctions work... The blackjack program is an example for sets, not
junctions.
The blackjack program is an excellent example for junctions (and not so good for sets, IMHO). The problem in the example above is that the calculation of the value of a hand was not completed. The complete calculation is as follows:

   my $pa = ([+] @a).eigenstates.grep{$_ <21}.max

If the result is undef, then the @a hand is a bust, and comparing $pa to a similarly calculated $pb is sane.

Henry
daniel


Reply via email to