emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Negative nth index


From: Teemu Likonen
Subject: Re: Negative nth index
Date: Tue, 24 Dec 2024 08:42:54 +0200
User-agent: Notmuch/0.38.3+15~g85c1dbd (https://notmuchmail.org) Emacs/30.0.93 (x86_64-pc-linux-gnu)

* 2024-12-24 00:11:26-0500, Stefan Monnier wrote:

> I don't see a strong argument in favor of making it index from the end
> rather than signal an error.  What would the implementation look like?
> Would it be significantly more efficient than doing it "by hand" e.g.:
>
>     (let ((l (length X)))
>       (nth (if (< i 0) (- l i) i) X))

First test if index (i) is negative and only then run the needed
"length" etc.

-- 
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 6965F03973F0D4CA22B9410F0F2CAE0E07608462

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]