$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;
}
use strict;
use warnings;
-use Test::More tests => 76;
+use Test::More tests => 79;
use Sub::Nary;
[ sub { do { 1; return 2, 3 } }, 2 ],
[ sub { do { 1; return 2, 3; 4 } }, 2 ],
[ sub { do { 1; return 2, return 3 } }, 1 ],
+ [ sub { do { return if $x; 2, 3 }, 4 }, { 0 => 0.5, 3 => 0.5 } ],
+ [ sub { do { do { return if $x }, 3 }, 4 }, { 0 => 0.5, 3 => 0.5 } ],
+ [ sub { do { return if $x; 2, 3 }, do { return 1 if $y; 4, 5, 6 } },
+ { 0 => 0.5, 1 => 0.25, 5 => 0.25 } ],
[ sub { return $x }, 1 ],
[ sub { return $x, $y }, 2 ],