[perl-python] Range function

Discussion in 'Perl Misc' started by Xah Lee, May 13, 2005.

  1. Xah Lee

    Xah Lee Guest

    Today we'll be writing a function called Range. The Perl documentation
    is as follows.

    Perl & Python & Java Solutions will be posted in 48 hours.

    This is Perl-Python a-day. See
    http://xahlee.org/web/perl-python/python.html

    Xah

    ∑ http://xahlee.org/

    --------------------------

    Range

    Range($iMax) generates the list [1, 2, ... , $iMax].

    Range($iMin, $iMax) generates the list [$iMin, ... , $iMax].

    Range($iMin, $iMax, $iStep) uses increment $iStep, with the last
    element
    in the result being less or equal to $iMax. $iStep cannot be 0. If
    $iStep is negative, then the role of $iMin and $iMax are reversed.

    If Range fails, 0 is returned.

    Example:

    Range(5); # returns [1,2,3,4,5]

    Range(5,10); # returns [5,6,7,8,9,10]

    Range( 5, 7, 0.3); # returns [5, 5.3, 5.6, 5.9, 6.2, 6.5, 6.8]

    Range( 5, -4, -2); # returns [5,3,1,-1,-3]
     
    Xah Lee, May 13, 2005
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xah Lee

    [perl-python] Range function

    Xah Lee, May 13, 2005, in forum: Python
    Replies:
    0
    Views:
    473
    Xah Lee
    May 13, 2005
  2. Xah Lee

    [perl-python] Range function

    Xah Lee, May 13, 2005, in forum: Python
    Replies:
    7
    Views:
    899
    David Formosa (aka ? the Platypus)
    May 16, 2005
  3. Replies:
    46
    Views:
    1,319
    Antoon Pardon
    Jul 25, 2006
  4. Lambda
    Replies:
    2
    Views:
    564
    James Kanze
    Jul 16, 2008
  5. Tomoyuki Kosimizu

    Range does not take an Range object.

    Tomoyuki Kosimizu, Nov 25, 2003, in forum: Ruby
    Replies:
    3
    Views:
    276
    Tomoyuki Kosimizu
    Nov 27, 2003
  6. David Bird
    Replies:
    1
    Views:
    455
    Tiago Macedo
    Jun 23, 2008
  7. Joey Zhou
    Replies:
    5
    Views:
    417
    Joey Zhou
    Apr 15, 2011
  8. Xah Lee

    [perl-python] Range function

    Xah Lee, May 13, 2005, in forum: Perl Misc
    Replies:
    7
    Views:
    226
    Jay Tilton
    May 16, 2005
Loading...