R
R
Rostyk Ice2016-09-28 20:37:52
Perl
Rostyk Ice, 2016-09-28 20:37:52

Can anyone explain what this part of the code does?

sub two {
        my @first;
        my @second;
        my $f0 = $_[0];
        my $s0 = $_[1];
  my $aline = $_[2];
  my $gline = $_[3];
        my ($i,$j,$prob);
  my ($wo, $w, $wu, $do, $d, $du, $lo, $l, $lu);
  $wo = $w = $wu = $do = $d = $du = $lo = $l = $lu = 0;
        $first[0] = exp(-$f0);
        $second[0] = exp(-$s0);
        for ($i = 1; $i < 20; $i++) {
                $first[$i] = $first[$i-1]*$f0/$i;
                $second[$i] = $second[$i-1]*$s0/$i;
        }
        for ($i = 0; $i < 20; $i++) {
                for ($j = 0; $j < 20; $j++) {
      $prob = $first[$i]*$second[$j];
      if ($i + $aline > $j) {
        if ($i+$j > $gline) {
          $wo += $prob;
        } elsif ($i+$j < $gline) {
          $wu += $prob;
        } else { $w += $prob;}
      } elsif ($i + $aline < $j) {
        if ($i+$j > $gline) {
          $lo += $prob;
        } elsif ($i+$j < $gline) {
          $lu += $prob;
        } else { $l += $prob;}
      } else {
        if ($i+$j > $gline) {
          $do += $prob;
        } elsif ($i+$j < $gline) {
          $du += $prob;
        } else { $d += $prob;}
      }
                }
        }
        return ($wo, $w, $wu, $do, $d, $du, $lo, $l, $lu);
}

And if you have a desire to help parse another 160 lines of code for a fee, then please write.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2016-09-28
@NiceIce

It's not the complexity of the code, it's just mathematical calculations, some order of numbers is calculated.
$first[$i] = $first[$i-1]*$f0/$i;
The input is four parameters, returns an array of data.

V
Vladimir Sergeevich, 2016-09-30
@frisarix

Sroll you do not diva and window;
For scrolling to occur in a div, its height must be less than the height of its content
codepen.io/anon/pen/VKzRPa

A
Albert Kazan, 2016-09-30
@Farrien

codepen.io/anon/pen/KgvEyG

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question