emacs-devel
[Top][All Lists]
Advanced

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

Re: request for a new function, say, `sequence'


From: Richard Stallman
Subject: Re: request for a new function, say, `sequence'
Date: Thu, 03 Apr 2003 17:52:18 -0500

    How about the following implementation:

       (defun number-sequence (from &optional to)
         "Return a sequence of numbers from FROM to TO (both inclusive) as a 
list.
       The Nth element of the list is (+ FROM N) where N counts from zero.
       If TO is nil, it defaults to FROM.
       If TO is less than FROM, the value is nil."
         (unless to
           (setq to from))
         (let ((seq nil))
           (while (>= to from)
             (push to seq)
             (setq to (1- to)))
           seq))

That is much cleaner.  However, to do the right thing with floats,
it should count up from FROM and then call nreverse.




reply via email to

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