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

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

Re: require basic stuff from specific packages


From: Udyant Wig
Subject: Re: require basic stuff from specific packages
Date: Tue, 09 Aug 2016 19:46:00 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Did you try an implementation like this for your functionality?


(require 'cl-lib)

(defun* string-number-sequnce (start end &optional (step 1) (separator " "))
  "Return a string of the integer sequence from START to END by an optional 
STEP.

The optional third argument STEP denotes the increment of the sequence.
The optional fourth argument SEPARATOR denotes the string to insert between 
members."
  (mapconcat #'identity (cl-loop for i from start to end by step
                                 collect (format "%d" i))
             separator))

(string-number-sequnce 1 10)
=> "1 2 3 4 5 6 7 8 9 10"
(string-number-sequnce 3 5 3)
=> "3"
(string-number-sequnce 5 15 2)
=> "5 7 9 11 13 15"
(string-number-sequnce 20 30 3 ", ")
=> "20, 23, 26, 29"


-- 
Udyant Wig


reply via email to

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