Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: easy
On 09/23/2015 12:45 PM, Bart Schaefer wrote:
} $ test () { echo @[2,-1]; }
Presume you're missing a $ in $@ there ...
Pardon.
} $ test one two three four five
} two three four five
}
If you grasp that indexing from the left starts at one rather than
at zero, why is it not "intuitive" that indexing from the right also
starts at (negative) one rather than zero?
Ah. I was trying to make sense of it as 'subtract one element from the
end'. Which would
make more sense as 'subtract zero elements from the end' (in this
case). But as 'echo
from the second element from the left up to the first element from the
right', then
'-1' is not a 'subtraction' rather it is the last element AKA the first
element from the right.
Perfectly logical as I thought it would be. Tx. Once you see the
logic in something
you can never forget it cuz it makes sense, as that does. Actually
that's much
better anyway because both numbers are indices rather than one being an
index
and one being a mathematical operation. Just hafta remember that the dash
does not mean subtraction, rather it means index from the right.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author