From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?B?TWF0w7rFoQ==?= Goljer Newsgroups: gmane.emacs.devel Subject: [PATCH] seq.el: add seq-last for symmetry with seq-first Date: Tue, 14 Mar 2023 13:55:03 +0100 Message-ID: <871qlrmr14.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24337"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 14 14:12:50 2023 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 1pc4SO-0006Ap-GI for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Mar 2023 14:12:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc4S7-0000Qh-CY; Tue, 14 Mar 2023 09:12:31 -0400 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 1pc4BK-00032W-D9 for emacs-devel@gnu.org; Tue, 14 Mar 2023 08:55:11 -0400 Original-Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pc4BI-0001Ws-7Q for emacs-devel@gnu.org; Tue, 14 Mar 2023 08:55:10 -0400 Original-Received: by mail-ed1-x52c.google.com with SMTP id y4so32164982edo.2 for ; Tue, 14 Mar 2023 05:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678798505; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=nEtivvohJtFgkEb0xOkSZkxIi/7u+zUK66rExOQydXI=; b=nxvCjlQyVMhEpr9z/5SpyhXHvJoc+s7Q7cgj8Zbx6WyN2xDT20U9qU5mK/DgG02N9B iI2C4l578o7PxGZ/4ysSIOJ7XPW2RccXZu+MqJeqETb2s2ulnub92EiFTUSNvRxNItjV 5C4ZR2n5xFCSJFBBPxccO5Q3O3lggx9r98xvYiuDHvMGP4vocUVBp57rbl5OWAuDFVtL k1SiLW3P9iPkNJru7fTBVVLsWQrVSNDGcdBR5mMzA1klIGiXnGA2KXXUXUajgKG2Yy+h 8tDem6+anxuQUnDVJEEvV8UJGL+IbKX05SSaeMy3iL3u9MT8yRL5oc+Y2BBlUyq9sTNJ Wi4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678798505; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nEtivvohJtFgkEb0xOkSZkxIi/7u+zUK66rExOQydXI=; b=60EBGACMYDCQCKISAbpRmjouTDtofMwgyHfWAeqXfBM/uBu5nsTDWHni/gfI2gSmO1 efF3GaGOBMC2FC40obqYlskYfpii72c84+SGphEH4E/P2UVJd2+7JC5qyFArorQToYLo YYiWgaLR6wNIPY44fLuT2kXOQcz5T5JM8Cz1cClTbPnvcvBimc90goL5+PKIxDgJdlcl mOqjYxiIIM6ty/IpBAzWKOsvzNaAltpjESlnR5HlXH6wVjD82Xlylu8do94Rv6rMrSfz 5TZkU7hTgZPpAuxejXQzaHDwUMXoNaV3IigHCbxnOjNtdz54oSoHSxYL6CEhY8mSj/Vp IwTg== X-Gm-Message-State: AO0yUKVwDTgHHnjgBxZMLlnNNlNGSeB07wgkHjITkieyGOqipzMM+ZOS Ynimm4jMsVr98zUF7YYk8skO61Zuvzzd8w== X-Google-Smtp-Source: AK7set+Eq9a1EdfLM7AECOY173/4mUYU9Uo6MBGlnzHcAp4PPzk75fW4GxBCdTJ1b4TqlsTUUMGP1Q== X-Received: by 2002:a17:906:58c6:b0:92b:e87a:5d8b with SMTP id e6-20020a17090658c600b0092be87a5d8bmr3146311ejs.35.1678798504811; Tue, 14 Mar 2023 05:55:04 -0700 (PDT) Original-Received: from parmenides (ip-89-177-55-133.bb.vodafone.cz. [89.177.55.133]) by smtp.gmail.com with ESMTPSA id yz6-20020a170906dc4600b00882f9130eafsm1117254ejb.26.2023.03.14.05.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 05:55:04 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=matus.goljer@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 14 Mar 2023 09:12:29 -0400 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:304440 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sometimes I want to get the last element of sequence and (seq-elt seq (1- (seq-length seq)) adds too much noise. This patch adds a simple wrapper around that. --=20 Best regards, Mat=C3=BA=C5=A1 Goljer --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-seq.el-add-seq-last-for-symmetry-with-seq-first.patch Content-Description: [PATCH] seq.el: add seq-last for symmetry with seq-first >From f3ef1a282d0aa1f4c2a21c946845516d0caf8c31 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Tue, 14 Mar 2023 13:46:10 +0100 Subject: [PATCH] seq.el: add seq-last for symmetry with seq-first --- lisp/emacs-lisp/seq.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 6917c541f2e..2571b558c95 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -124,6 +124,10 @@ name to be bound to the rest of SEQUENCE." "Return the first element of SEQUENCE." (seq-elt sequence 0)) +(defun seq-last (sequence) + "Return the last element of SEQUENCE." + (seq-elt sequence (1- (seq-length sequence)))) + (defun seq-rest (sequence) "Return SEQUENCE with its first element removed." (seq-drop sequence 1)) -- 2.34.1 --=-=-=--