X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FSub%2FNary.pm;h=b6ad798ebbe50604af0198ef7d183e8ebb90e5f2;hb=f73405816c83f0e2816e81421a8b6cf72d5e3151;hp=611f780d617ad220649149b56ab64094db53cb59;hpb=fd35681c6f0a1e84d407dbe4fcc7a3c25e4d8851;p=perl%2Fmodules%2FSub-Nary.git diff --git a/lib/Sub/Nary.pm b/lib/Sub/Nary.pm index 611f780..b6ad798 100644 --- a/lib/Sub/Nary.pm +++ b/lib/Sub/Nary.pm @@ -273,7 +273,7 @@ sub inspect { if (null $op) { # If the logop has no else branch, it can also return the *scalar* result of # the conditional - $l3 = { 1 => $c }; + $l3 = { 1 => 1 }; } else { ($r3, $l3) = $self->inspect($op); } @@ -311,18 +311,20 @@ sub inspect_kids { $op = $op->first; redo; } - diag "> $n ($c)" if $DEBUG; + diag "> $n" if $DEBUG; my ($rc, $lc) = $self->inspect($op); + $c = 1 - count $r; + diag Dumper [ $c, $r, \@l, $rc, $lc ] if $DEBUG; $r = add $r, scale $c, $rc if defined $rc; - if ($rc and not defined $lc) { + if (not defined $lc) { @l = (); last; } push @l, scale $c, $lc; - $c *= count $lc if defined $lc; } - my $l = combine @l; +# diag Dumper \@l if $DEBUG; + my $l = scale +(1 - count $r), normalize combine @l; return $r, $l; }