;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/sequence-string.el (require 'cl-lib) (defun seq-str (beg end &optional step delim suffix) (or step (setq step 1)) (or delim (setq delim " ")) (or suffix (setq suffix "")) (let ((str (format "%s%s" beg suffix))) (cl-loop for n from (+ beg step) to end by step do (setq str (format "%s%s%s%s" str delim n suffix)) ) (string-trim str) )) ;; (seq-str 1 10) ; 1 2 3 4 5 6 7 8 9 10 ;; (seq-str 3 5 3) ; 3 ;; (seq-str 5 15 2) ; 5 7 9 11 13 15 ;; (seq-str 20 30 3 ", ") ; 20, 23, 26, 29 ;; (seq-str 1 15 2 " " ".pdf") ; 1.pdf 3.pdf ... 15.pdf ;; (seq-str 2 15 2 " " ".pdf") ; 2.pdf 4.pdf ... 14.pdf (provide 'sequence-string)