Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Python

Idiom #303 Array with non-default lower bound

Declare an array a of integers with six elements, where the first index is 42 and consecutive elements have the indices 43, 44, 45, 46, 47.

import array
a = array.array("i", range(42,48))

The type of values stored in the array is constrained to a single type (given as a typecode in the first argument).
A : array (42 .. 47) of Integer;

A'First is 42, A'Last is 47, A'Length is 6.

New implementation...
< >
tkoenig