in reply to Re^3: Any idea for predicting the peak points in the graph by perl
in thread Any idea for predicting the peak points in the graph by perl

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^4: Any idea for predicting the peak points in the graph by perl

Replies are listed 'Best First'.
Re^5: Any idea for predicting the peak points in the graph by perl
by tlm (Prior) on Apr 18, 2005 at 13:44 UTC
    use strict; my $input_file = 'foobar.txt'; open my $in, $input_file or die "Failed to read $input_file: $!\n"; my @max = do { local $_ = <$in>; chomp; [ split ] }; my $last = $max[ 0 ][ 1 ]; while ( <$in> ) { chomp; my ( $x, $y ) = split; if ( $y > $last ) { $max[ -1 ] = [ $x, $y ]; } elsif ( $max[ -1 ] ) { $max[ @max ] = undef; } $last = $y; } close $in; pop @max unless $max[ -1 ]; print "Maxima:\n"; print "($_->[ 0 ], $_->[ 1 ])\n" for @max;

    Update: fixed missing my before $in

    the lowliest monk