unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: number-sequence
Date: Thu, 20 Nov 2003 15:27:22 +0200	[thread overview]
Message-ID: <87smkji35l.fsf@mail.jurta.org> (raw)
In-Reply-To: <200311200339.hAK3dGE07492@raven.dms.auburn.edu> (Luc Teirlinck's message of "Wed, 19 Nov 2003 21:39:16 -0600 (CST)")

Luc Teirlinck <teirllm@dms.auburn.edu> writes:
> (number-sequence 1 3 -1) or (number-sequence 1 3 0)

There is another case that makes sense: if INC is nil and TO is less
than FROM, then INC could default to -1, i.e.

    (number-sequence 3 1) => (3 2 1)

To do this you could replace in your version:

- If INC is nil, it defaults to 1 (one).
+ If INC is nil, it defaults to 1 (one) if TO is larger than FROM,
+ or to -1 if TO is less than FROM.

-     (or inc (setq inc 1))
+     (or inc (setq inc (if (< from to) 1 -1)))

BTW, it couldn't hurt to add examples to the docstring:

Examples:
    (number-sequence 1) => (1)
    (number-sequence 1 1) => (1)
    (number-sequence 1 3) => (1 2 3)
    (number-sequence 1 3 2) => (1 3)
    (number-sequence 3 1) => (3 2 1)
    (number-sequence 3 1 -2) => (3 1)

-- 
http://www.jurta.org/emacs/

  parent reply	other threads:[~2003-11-20 13:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-20  3:39 number-sequence Luc Teirlinck
2003-11-20 10:39 ` number-sequence Kim F. Storm
2003-11-20 13:27 ` Juri Linkov [this message]
2003-11-21  4:37   ` number-sequence Luc Teirlinck
2003-11-21 12:06     ` number-sequence Kim F. Storm
2003-11-21 14:43       ` number-sequence Luc Teirlinck
2003-11-23 16:09   ` number-sequence Luc Teirlinck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87smkji35l.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).