GNU bug report logs -
#67456
[PATCH] seq.el: Add functions for mapping over subsequences
Previous Next
Reported by: Okamsn <okamsn <at> protonmail.com>
Date: Sun, 26 Nov 2023 17:19:01 UTC
Severity: wishlist
Tags: moreinfo, patch
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 67456 <at> debbugs.gnu.org (full text, mbox):
Okamsn <okamsn <at> 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.
This bug report was last modified 84 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.