From: Mark Oteiza <mvoteiza@udel.edu>
To: emacs-devel@gnu.org
Subject: Re: What about seq-slice?
Date: Fri, 30 Jan 2015 12:17:28 -0500 [thread overview]
Message-ID: <871tmcb32v.fsf@udel.edu> (raw)
In-Reply-To: <87k304ef9k.fsf@petton.fr> (Nicolas Petton's message of "Fri, 30 Jan 2015 11:25:59 +0100")
Nicolas Petton <nicolas@petton.fr> writes:
> Mark Oteiza <mvoteiza@udel.edu> writes:
>> Coincidentally, I had been thinking about additions to seq.el. I'm
>> interested in having a function like Ruby's each_slice[0] method. For
>> example,
>>
>> (defun seq-slice (seq n)
>> "Return a list of subsequences of SEQ, each a sequence of
>> length N. The last subsequence may have less than N elements.
>>
>> If N is a negative integer or zero, a list containing SEQ is
>> returned."
>> (if (or (<= n 0)
>> (>= n (seq-length seq)))
>> (list seq)
>> (let ((copy (seq-copy seq))
>> (result '()))
>> (while (not (seq-empty-p copy))
>> (push (seq-take copy n) result)
>> (setq copy (seq-drop copy n)))
>> (nreverse result))))
>>
>> I didn't think dash.el had it until I realized it is named something
>> else: -partition-all[1].
>>
>> [0]: http://ruby-doc.org/core-2.2.0/Enumerable.html#method-i-each_slice
>> [1]: https://github.com/magnars/dash.el/blob/master/dash.el#L730
>
> Hi Mark,
>
> I'm not sure I understand how to use it. In which scenario would you
> find `seq-slice' useful?
When one has a large number of things but is only "allowed" to use N of
them at a time. For instance, a large number of usernames and an API
that limits the number of users in a single query.
prev parent reply other threads:[~2015-01-30 17:17 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 16:54 Would seq-range and seq-mapcat be useful? Nicolas Petton
2015-01-29 18:02 ` Artur Malabarba
2015-01-29 22:03 ` Nicolas Petton
2015-01-29 21:40 ` Stefan Monnier
2015-01-29 22:06 ` Nicolas Petton
2015-01-30 6:09 ` Stefan Monnier
2015-01-30 8:00 ` Oleh Krehel
2015-01-30 10:21 ` Nicolas Petton
2015-01-30 15:38 ` Oleh Krehel
2015-01-30 15:59 ` Nicolas Richard
2015-01-30 16:04 ` Oleh Krehel
2015-01-30 16:05 ` Oleh Krehel
2015-01-30 16:36 ` Nicolas Richard
2015-01-30 16:51 ` Oleh Krehel
2015-01-30 16:23 ` Nicolas Petton
2015-02-02 0:11 ` Nicolas Petton
2015-02-02 7:49 ` Oleh Krehel
2015-02-02 9:28 ` Nicolas Petton
2015-02-02 18:34 ` Mark Oteiza
2015-02-02 18:39 ` Oleh Krehel
2015-02-04 12:02 ` Ted Zlatanov
2015-01-30 8:20 ` What about seq-slice? (Was: Would seq-range and seq-mapcat be useful?) Mark Oteiza
2015-01-30 10:25 ` Nicolas Petton
2015-01-30 11:09 ` seq-thread-first/last (was: What about seq-slice?) Michael Heerdegen
2015-01-30 11:59 ` Nicolas Petton
2015-01-30 12:08 ` seq-thread-first/last Michael Heerdegen
2015-01-30 12:21 ` seq-thread-first/last Nicolas Petton
2015-01-30 12:17 ` seq-thread-first/last David Kastrup
2015-01-30 12:25 ` seq-thread-first/last Nicolas Petton
2015-01-30 12:33 ` seq-thread-first/last Michael Heerdegen
2015-01-30 12:58 ` seq-thread-first/last Bozhidar Batsov
2015-01-30 14:02 ` seq-thread-first/last Artur Malabarba
2015-01-30 14:15 ` seq-thread-first/last Michael Heerdegen
2015-01-30 17:17 ` Mark Oteiza [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=871tmcb32v.fsf@udel.edu \
--to=mvoteiza@udel.edu \
--cc=emacs-devel@gnu.org \
/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.