From: Philip Kaludercic <philipk@posteo.net>
To: Okamsn <okamsn@protonmail.com>
Cc: nicolas@petton.fr, 67456@debbugs.gnu.org
Subject: bug#67456: [PATCH] seq.el: Add functions for mapping over subsequences
Date: Mon, 25 Dec 2023 20:26:18 +0000 [thread overview]
Message-ID: <87tto6rpud.fsf@posteo.net> (raw)
In-Reply-To: <6f6d9f2d-fee9-4d1d-a1e4-8c6ce57a0627@protonmail.com> (okamsn@protonmail.com's message of "Sun, 26 Nov 2023 17:17:35 +0000")
Okamsn <okamsn@protonmail.com> writes:
> Hello,
>
> The attached features work like `cl-maplist` and `cl-mapl`, applying
> functions to a sequence and to the remaining parts of a sequence. For
> example, `(seq-mapsub #'identity [1 2 3])` returns `([1 2 3] [2 3] [3])`.
>
> The patch adds a `seq-mapsub`, `seq-dosub`, and a `seq-doseqsub`,
> similar to `seq-map`, `seq-do`, and `seq-doseq`, respectively.
How about adding a custom sequence type, that operates on sub-sequences
as elements?
--8<---------------cut here---------------start------------->8---
(cl-defstruct (subseq (:constructor seq-make-subseq (seq))) seq)
(cl-defmethod seq-elt ((seq subseq) n)
(seq-subseq (subseq-seq seq) n (seq-length seq)))
(cl-defmethod seq-length ((seq subseq))
(seq-length (subseq-seq seq)))
(cl-defmethod seq-do (fn (seq subseq))
(seq-do fn (subseq-seq seq)))
;; etc.
--8<---------------cut here---------------end--------------->8---
It might not be that efficient either, but at least it doesn't require
more functions.
prev parent reply other threads:[~2023-12-25 20:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-26 17:17 bug#67456: [PATCH] seq.el: Add functions for mapping over subsequences Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-28 1:29 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-01 20:14 ` Augusto Stoffel
2023-12-03 1:25 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-25 20:26 ` Philip Kaludercic [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tto6rpud.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=67456@debbugs.gnu.org \
--cc=nicolas@petton.fr \
--cc=okamsn@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.