[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
negative index for the sequence
- To: gls@ZARATHUSTRA.THINK.COM
- Subject: negative index for the sequence
- From: Hiroshi G. Okuno <Okuno@SUMEX-AIM.ARPA>
- Date: Sat 21 Jun 86 00:27:34-PDT
- Cc: common-lisp@SU-AI.ARPA
- In-reply-to: <860619212728.1.GLS@THORLAC.THINK.COM>
> Well, SUBSEQ must check the length if it is defined to SIGNAL an error for
> an out-of-bound index.
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.
(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 -