Help for this page

Select Code to Download


  1. or download this
    our @s = map { sin(0.18*$_) + rand(0.6) - 0.3 } 0 .. 99;
    
  2. or download this
    our(@xlo, @xhi); my $t = my $t0 = $s[0] < 0; for my $x (0 .. @s - 1) {
    + if ($t) { if ($s[$x] > 0.5) { $t = 0; push @xhi, $x; } } else { if (
    +$s[$x] < -0.5) { $t = 1; push @xlo, $x; } } }
    
  3. or download this
    our(@xmi, @xma); for my $p (0 .. @xlo - 1) { my $xmi = $xlo[$p]; for m
    +y $x ($xlo[$p] .. ($xhi[$p + $t0] || @s) - 1) { $s[$x] < $s[$xmi] and
    + $xmi = $x; } push @xmi, $xmi; } for my $p (0 .. @xhi - 1) { my $xma 
    += $xhi[$p]; for my $x ($xhi[$p] .. ($xlo[$p + 1 - $t0] || @s) - 1) { 
    +$s[$xma] < $s[$x] and $xma = $x; } push @xma, $xma; }
    
  4. or download this
    for my $x (0 .. @s - 1) { my $l = " "x15 . ":" . " "x15; if (@xlo && $
    +xlo[0] <= $x) { shift @xlo; substr $l, 0, 10, "v"x10; } elsif (@xhi &
    +& $xhi[0] <= $x) { shift @xhi; substr $l, 20, 10, "v"x10; } if (@xmi 
    +and $xmi[0] <= $x) { shift @xmi; substr $l, 0, 7, "minimum"; } elsif 
    +(@xma and $xma[0] <= $x) { shift @xma; substr $l, 23, 7, "maximum"; }
    + substr $l, 15+int(10*$s[$x]), 1, "*"; print $l, "\n"; }
    
  5. or download this
                   *               
                  *:               
    ...
    minim*m        :               
           *       :               
            *      :