unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Doing something different for the last element of a sequence (partition)?
@ 2020-11-16 10:28 Tim Landscheidt
  2020-11-16 11:10 ` 2QdxY4RzWzUUiLuE
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Landscheidt @ 2020-11-16 10:28 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I have a list of URLs (all-urls) and I want to launch a
Firefox window for the first x URLs, then wait y seconds,
then launch another one, etc., and then prompt the user if
the source of URLs can be deleted (provided that everything
went smoothly).

If I do:

| (seq-doseq (firefox-urls (seq-partition (seq-sort all-urls #'string<) x))
|   (apply 'call-process "firefox" nil "*firefox*" nil firefox-urls)
|   (sleep-for y))

that works fine, except that it also waits for y seconds af-
ter the last launch.

Looking at seq's toolbox, it seems to me that the only way
to avoid that last sleep would be:

- seq-sort the URLs alphabetically,
- then seq-partition,
- then seq-reverse,
- then use seq-map-indexed to add the indexes to the subse-
  quences in a kind of Schwartzian transform, marking the
  logically last partition with the index 0,
- then seq-reverse,
- then seq-doseq and sleep only if the index is not 0.

Ugh.  Is there something I missed?  Some form of mapconcat
that accepts a function as separator?

Tim




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-16 11:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-16 10:28 Doing something different for the last element of a sequence (partition)? Tim Landscheidt
2020-11-16 11:10 ` 2QdxY4RzWzUUiLuE
2020-11-16 11:40   ` Tim Landscheidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).