Help for this page

Select Code to Download


  1. or download this
       my $sum = 0;
       $sum += ($weights[$_]||0) * ($digits[$_]||0) for 0 .. @#weights;
    
  2. or download this
       my $sum = 0;
       for (0..@#weights) {
    ...
       }
    # or yet another:
       $sum += $weights[$_] * $digits[$_] for grep $weights[$_] && $digits
    +[$_], 0..@#weights;