in reply to Re: Stuck Value
in thread Stuck Value

I am processing environmental variables (hourly measurements) and we declared variables as stuck if we have 5 instances of no-change.

Replies are listed 'Best First'.
Re^3: Stuck Value
by anonymized user 468275 (Curate) on Dec 02, 2010 at 16:10 UTC
    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