Ah, this makes sense at some wacky level.

Consider this array (language doesn't matter here, so this is pseudo-code):

array = ('a', 'b', 'c', 'd', 'e')

Some languages use a convention where begin(array) is equivalent to array[0], and end(array) is equivalent to array[5], or one past the last element. A loop in such a world might be written like this:

for (x = 0; x != end(array); ++x) do_something(array, x);

The notation used for such a concept is sometimes this:

[0,5)

...meaning (0 <= x < 5). This concept and notation is common in C++. And is used by Python's range() function.

Python's range method has the following semantics:

range(stop) # 0 .. stop-1 range(start,stop) # start .. stop-1 range(start,stop,step) # start .. stop-1 by step: for(ix=0; ix != sto +p; ix += step) {...}

In each case start is inclusive, and stop is exclusive. [start,stop) in mathematical notation, or this: (start <= x < stop).


Dave


In reply to Re^3: [OT] Python to Perl. by davido
in thread [OT] Python to Perl. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.