In the Python implementation is 'start' always smaller than 'end'?
Not sure, I am actually quite Green in Python.
The whole idea would be to get rid of having to keep a separate index in for loop.
Mind you, it still would not be equivalent to a For... Next as the range is compute beforehand
and you cannot modify it while the loop is running.
It does have the advantage of being quite readable. But again would there be a hit on speed ?
We certainly are using more memory but this get freed eventually.
I like!!! Cab's offering, the only problem with it is that it includes end,
(in_range 0 5 1) should return (0 1 2 3 4), but is easy to fix.
ymg
Here from:
docs.python.orgrange(start, stop[, step])
This is a versatile function to create lists containing arithmetic progressions. It is most often used in for loops. The arguments must be plain integers. If the step argument is omitted, it defaults to 1. If the start argument is omitted, it defaults to 0. The full form returns a list of plain integers [start, start + step, start + 2 * step, ...]. If step is positive, the last element is the largest start + i * step less than stop; if step is negative, the last element is the smallest start + i * step greater than stop. step must not be zero (or else ValueError is raised). Example:
>>>
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1, 11)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> range(0, 30, 5)
[0, 5, 10, 15, 20, 25]
>>> range(0, 10, 3)
[0, 3, 6, 9]
>>> range(0, -10, -1)
[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
>>> range(0)
[]
>>> range(1, 0)
[]