From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#67456: [PATCH] seq.el: Add functions for mapping over subsequences Date: Mon, 25 Dec 2023 20:26:18 +0000 Message-ID: <87tto6rpud.fsf@posteo.net> References: <6f6d9f2d-fee9-4d1d-a1e4-8c6ce57a0627@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29351"; mail-complaints-to="usenet@ciao.gmane.io" Cc: nicolas@petton.fr, 67456@debbugs.gnu.org To: Okamsn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 25 21:27:07 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rHrXW-0007La-PN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 Dec 2023 21:27:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rHrXQ-0003ZG-MC; Mon, 25 Dec 2023 15:27:00 -0500 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 1rHrXN-0003Yt-Eb for bug-gnu-emacs@gnu.org; Mon, 25 Dec 2023 15:26:57 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rHrXL-00041e-M1 for bug-gnu-emacs@gnu.org; Mon, 25 Dec 2023 15:26:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rHrXS-00054o-1O for bug-gnu-emacs@gnu.org; Mon, 25 Dec 2023 15:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Dec 2023 20:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67456 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67456-submit@debbugs.gnu.org id=B67456.170353600019481 (code B ref 67456); Mon, 25 Dec 2023 20:27:02 +0000 Original-Received: (at 67456) by debbugs.gnu.org; 25 Dec 2023 20:26:40 +0000 Original-Received: from localhost ([127.0.0.1]:55439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rHrX5-000549-Lv for submit@debbugs.gnu.org; Mon, 25 Dec 2023 15:26:39 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:49385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rHrWz-00053n-Tw for 67456@debbugs.gnu.org; Mon, 25 Dec 2023 15:26:37 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 084A0240028 for <67456@debbugs.gnu.org>; Mon, 25 Dec 2023 21:26:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1703535981; bh=vRksafUxQl4LABZIf3OC0/JemvqKMokv9Jl2yuo53jM=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: From; b=FqL5EtVM4XPvAEN16yo5coRMsX5X9goC+pxJ+uFbbCoXwSXSd6BeJ5twok1Wh/nsF 1RKm4I4oL8W5PsKAhfzEz88pioDNB6cI+Qgz6VPE5ons0aZ1WjAz2ArpuHOuc1y+3c zuGZ66D+4jRR05iVfBjkCU0OSBW2oLoo6Nd9/O55uALgBFDkn7F0KEyZ5xZUQA/b5g 9jNazwqlYgTJOCgG0fUg/i7fkwk+w77rfwaNAg7dcTl19cr4a9dKU6wbflzkqlvo0T 7MyDXmAhxJC4O+N74fMYPcxbXleG1OHA+D0x7g96sWNLWbFEoYZJ5stIvakqg8W8Dw SxFaukHT7LD+g== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SzTvJ13NHz9rxB; Mon, 25 Dec 2023 21:26:20 +0100 (CET) In-Reply-To: <6f6d9f2d-fee9-4d1d-a1e4-8c6ce57a0627@protonmail.com> (okamsn@protonmail.com's message of "Sun, 26 Nov 2023 17:17:35 +0000") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276891 Archived-At: Okamsn 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.