help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Doing something different for the last element of a sequence (partition)


From: Tim Landscheidt
Subject: Doing something different for the last element of a sequence (partition)?
Date: Mon, 16 Nov 2020 10:28:52 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]