bug-coreutils
[Top][All Lists]
Advanced

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

Re: seq increment '1' even when first > last?


From: Jim Meyering
Subject: Re: seq increment '1' even when first > last?
Date: Tue, 20 Jun 2006 12:02:14 +0200

Tim Waugh <address@hidden> wrote:
> I'm trying to work out what prompted this change:
>
> 2003-09-04  Paul Eggert  <address@hidden>
>
>         * src/seq.c (step): Default to 1.
>         (print_numbers): Allow the output to be empty.
>         (main): The default step is 1, even if LAST < FIRST;
>         as per documentation.
>
> The original behaviour, of automatically defaulting to -1 when
> appropriate, seems on the face of it to be quite useful.  I wonder why
> the code was changed to match the documentation, rather than the other
> way around.

Hi Tim,

Some Debian users noticed this, too.  I explained here:

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=234417;msg=32

For the full thread, see http://bugs.debian.org/234417

If you're in a bad mood, you can reply tersely:

  Don't rely on undocumented behavior.

:-)

Part of the justification is that some programming languages
provide constructs that work that way (e.g., FORTRAN, Perl, Python, Ruby).

Also, from a consistency standpoint, the new behavior makes more sense:

    $ seq 1 3
    1
    2
    3
    $ seq 1 2
    1
    2
    $ seq 1 1
    1
    $ seq 1 0
    $

Demonstrating with Ruby:

    $ ruby -e 'puts (1..3).to_a'
    1
    2
    3
    $ ruby -e 'puts (1..2).to_a'
    1
    2
    $ ruby -e 'puts (1..1).to_a'
    1
    $ ruby -e 'puts (1..0).to_a'
    $




reply via email to

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