in reply to Stuck Value

...and beware that you can't test the first set of values for non-changing. Further, people already think you want to test local pairs of instances for stuck values -- it is more likely you want to check for similarity over more than two instances before flagging it stuck. How many instances of no-change is enough to be declared stuck?

One world, one people

Replies are listed 'Best First'.
Re^2: Stuck Value
by halligalli (Novice) on Dec 02, 2010 at 13:22 UTC
    I am processing environmental variables (hourly measurements) and we declared variables as stuck if we have 5 instances of no-change.
      ok then to index the last five elements of an array say @arr up to and including $i, use the array slice
      $arr[ ($i - 4) .. $i ]
      update: and to avoid trying to index below 0: and suggesting an inequality function:
      my $h = $i - 4; if ( $h >= 0 ) { if (unequal ( $arr[ $h .. $i ] ) { # flag stuck value } } # ... sub unequal { my %v = map { ($_, 1 ); } @_; my @v = keys %v; return $#v; }

      One world, one people