in reply to Re^4: Efficient array element deletion
in thread Efficient array element deletion

Here's another approach to accessing the elements of an array in reverse order without creating a list:

@a = 1 .. 9;; print "$_ : -$_ : $a[ -$_ ]" for 1 .. @a;; 1 : -1 : 9 2 : -2 : 8 3 : -3 : 7 4 : -4 : 6 5 : -5 : 5 6 : -6 : 4 7 : -7 : 3 8 : -8 : 2 9 : -9 : 1

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^6: Efficient array element deletion
by kennethk (Abbot) on Dec 07, 2008 at 15:33 UTC
    This is actually what I meant to do originally, I just didn't quite understand how negative indices were interpreted.