]> git.vpit.fr Git - perl/modules/Sub-Nary.git/blobdiff - lib/Sub/Nary.pm
Fix handling of partial returns in lists
[perl/modules/Sub-Nary.git] / lib / Sub / Nary.pm
index 50ba378034fa54a17ab6a2e4366926528aa3e52f..b6ad798ebbe50604af0198ef7d183e8ebb90e5f2 100644 (file)
@@ -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;
 }