From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.devel Subject: Re: Negative nth index Date: Tue, 24 Dec 2024 08:42:54 +0200 Message-ID: <87jzbpeg41.fsf@iki.fi> References: <865xnc6u9n.fsf@gnu.org> <87jzbs9jlk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18129"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.38.3+15~g85c1dbd (https://notmuchmail.org) Emacs/30.0.93 (x86_64-pc-linux-gnu) Cc: Tassilo Horn , Eli Zaretskii , Anand Tamariya , emacs-devel@gnu.org To: Stefan Monnier , Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 24 07:43:23 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tPydW-0004aS-J5 for ged-emacs-devel@m.gmane-mx.org; Tue, 24 Dec 2024 07:43:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPydN-0005Ed-Mx; Tue, 24 Dec 2024 01:43:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPydL-0005EE-Qj for emacs-devel@gnu.org; Tue, 24 Dec 2024 01:43:11 -0500 Original-Received: from lahtoruutu.iki.fi ([185.185.170.37]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPydJ-0004pq-S8; Tue, 24 Dec 2024 01:43:11 -0500 Original-Received: from mithlond (mobile-access-567361-71.dhcp.inet.fi [86.115.97.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: tlikonen) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4YHQLt4Ljmz49Pyv; Tue, 24 Dec 2024 08:43:02 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1735022583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XgJ/NdLrSIrK6Svceo8kojkw/mD9wA8Lje72jKwgyJw=; b=kjfksbPhUZTUhULINshTle9c7H0ixBfbwZmnQE6s0DZSxcY0qz3ShMQ3OdcEK0spyuumE8 wHgufDgyEYlnSTDrObqjbxuBZ690dEVD/z7iq/4zpMR02RjUb/OsIUJQACvBEUF1+3o8Iu I1oK1oht7aLVw5EJnDDWdqWW82q2sdf1+1wABa3sAjAiaTaBzSAw14/73OIJCRdoa1Kjps IXerzXNLlzpXSv5gmEtjCUnFKUSnrBPHnEpP08GCLnlN15tYqcSjfjVWL3amT9Qcx56x3d yycJG8lgEMCd6NraHtuU8WvCBexuNRJfYG3JYfKRsQp+95Bup8QrdTCdwFDjGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1735022583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XgJ/NdLrSIrK6Svceo8kojkw/mD9wA8Lje72jKwgyJw=; b=mNdfxmMhhwFHqLJFGp7ujmMEw3ZpqvBQvgbznN0HpRlVCx9Aq46vcDzSk5YxQr9VeFaFou jsgdqKUYDn8W8Xw9vkqc/XfAqAcTwIkNY2rZqzweRPITxEE+GNfKjyOf4UCQW9eEhBVT1N ut/ywkaH6DOLVNFhBypvsHAg+zCj3krX6qVH4A0o/JZhiZM4YcFaM3PiU0g9sOj5xx/cHB x13i33R8EpjaHONyKsXeHG8w5cHOKdrxfPvz4PHyA2dxmB9dPGVmX1SJcwlviFHS4ipugx r9AEIyP/gdc/j3dW1d8cesBxsw+iSXbaBAs4/2ADUAN1Zgd5faa369lIptDWNQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1735022583; a=rsa-sha256; cv=none; b=fwY82GnQqFn62Tbg047UfjD+Kqi6pmSx++VD4zDJ7UHgSNBoXC9QUFQphQ1Vby2RH5LybY aSBPZzQR0HAM8O+WZmwwzUL6fXmBdzRl7C0lloSu6bKCkWCSACiuVsavPj3WTyKyTdlJjS XPZElTWNReQpqMtox0c3C5LL4UFLOESADneXR5NKI1bp1WC6sAAUO17qUUBEPWYSQdp6Oj 1ysg/lHAOlYP7NfgIaSDAO9Jm31wJRxkdxPaSC0BhZUiV9NKbbdDKJyOTi3a+TAaCEzb17 YW6tGqLW84lcGswveNnqhkS9I9oJiwEP6hwMjsxfMd7RR8p25r8CBFpAKaeWTg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=tlikonen smtp.mailfrom=tlikonen@iki.fi In-Reply-To: Received-SPF: pass client-ip=185.185.170.37; envelope-from=tlikonen@iki.fi; helo=lahtoruutu.iki.fi X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326969 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable * 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. =2D-=20 /// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/ // OpenPGP: 6965F03973F0D4CA22B9410F0F2CAE0E07608462 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIYEARYIAC4WIQQL23klfGMkeOvdGCt57xklfWtWWwUCZ2pX7hAcdGxpa29uZW5A aWtpLmZpAAoJEHnvGSV9a1ZbtgIA/1ZiGQOKbOh9IbPf093P6UDwHcj1JVDAZrE3 lWvGI5zZAQDs4ZESAiVzQncVd2dkhSumXeZNy7qRKZylm82NK2V7AQ== =IfpY -----END PGP SIGNATURE----- --=-=-=--