all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] seq.el: add seq-last for symmetry with seq-first
@ 2023-03-14 12:55 Matúš Goljer
  2023-03-14 15:26 ` Philip Kaludercic
  0 siblings, 1 reply; 9+ messages in thread
From: Matúš Goljer @ 2023-03-14 12:55 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

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.
-- 
Best regards,
  Matúš Goljer

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] seq.el: add seq-last for symmetry with seq-first --]
[-- Type: text/x-patch, Size: 823 bytes --]

From f3ef1a282d0aa1f4c2a21c946845516d0caf8c31 Mon Sep 17 00:00:00 2001
From: Matus Goljer <matus.goljer@gmail.com>
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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-15  8:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-14 12:55 [PATCH] seq.el: add seq-last for symmetry with seq-first Matúš Goljer
2023-03-14 15:26 ` Philip Kaludercic
2023-03-14 15:48   ` Matúš Goljer
2023-03-14 16:14     ` Philip Kaludercic
2023-03-14 18:35       ` Augusto Stoffel
2023-03-14 19:14         ` Matúš Goljer
2023-03-14 22:04         ` Philip Kaludercic
2023-03-15  7:06           ` Augusto Stoffel
2023-03-15  8:09             ` Philip Kaludercic

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.