GNU bug report logs - #67456
[PATCH] seq.el: Add functions for mapping over subsequences

Previous Next

Package: emacs;

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 #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: Okamsn <okamsn <at> protonmail.com>, nicolas <at> petton.fr, 67456 <at> debbugs.gnu.org
Subject: Re: bug#67456: [PATCH] seq.el: Add functions for mapping over
 subsequences
Date: Fri, 01 Dec 2023 21:14:13 +0100
On Tue, 28 Nov 2023 at 01:29, Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> Okamsn wrote:
>> 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.
>> 
>> I was looking for an equivalent for vectors of `cl-maplist`, `cl-mapl`,
>> and `cl-loop`'s `for VAR on LIST`, and think that these would be useful
>> additions.
>> 
>> To get the sub-sequences, the code uses `seq-rest` and stops when the
>> returned sub-sequence is empty according to `seq-empty-p`.  This is
>> similar to how I would do it for a list, using `cdr` and `null`, but is
>> that a good way to do it for arrays and other sequences?
>> 
>> Thank you.
>
> I've updated the patch to only add the one `seq-mapsub` function, to be 
> more like `seq-mapn` and `seq-mapcat`, and to add an optimized version 
> for lists.
>
> Would you like anything changed?
>
> Thank you.

This operation has quadratic complexity for anything other than regular
linked lists.  I'm not sure it's a good idea to add it to a generic
sequence library...




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.