in reply to Small examples of string eval

http://groups.google.com/group/comp.lang.perl.misc/msg/41264e99d9b0dc53?hl=en&

Replies are listed 'Best First'.
Re^2: Small examples of string eval
by ikegami (Patriarch) on May 14, 2006 at 04:24 UTC

    Check out NestedLoops in Algorithm::Loops. In this case,

    use Algorithm::Loops qw( NestedLoops ); use List::Util qw( reduce sum ); sub mul { return reduce { $a * $b } @_; } NestedLoops( [ map { [ 0..$n_ra->[$_] ] } 0..$#$n_ra ], sub { $prob_ra[sum @_] += mul map { $f_raa->[$_]->[$_[$_]] } 0..$#_; } );

    I suspect that
    $n_ra->[X]
    is equal to
    $#{$f_raa->[X]}
    in which case
    map { [ 0..$n_ra->[$_] ] } 0..$#$n_ra
    can be replaced with
    map { [ 0..$#$_ ] } @$f_raa