[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
negative index for the sequence
> Well, SUBSEQ must check the length if it is defined to SIGNAL an error for
> an out-of-bound index.
>
> --Guy
If the length check is performed in SUBSEQ, a negative index may be
considered as a convention of
-n == (- (length <object>) n) where n > 0.
For example,
(subseq #(a b c d e) -3 -1) = (subseq #(a b c d e) 2 4) = #(c d e)
Of course, if the non-negative index which corresponds to a negative one
exceeds the bound of the sequence, an error is signalled.
This convention is very useful for string manipulations. In fact,
a negative index is supported in TAO and used extensively in a
kana-kanji conversion programs.
- Gitchang -
-------