Array Slicing - Details


For "one-dimensional" (single-indexed) arrays — vectors, sequence, strings etc. — the most common slicing operation is extraction of zero or more consecutive elements. Thus, if we have a vector containing elements (2, 5, 7, 3, 8, 6, 4, 1), and we want to create an array slice from the 3rd to the 6th items, we get (7, 3, 8, 6). In programming languages that use a 0-based indexing scheme, the slice would be from index 2 to 5.

Reducing the range of any index to a single value effectively eliminates that index. This feature can be used, for example, to extract one-dimensional slices (vectors) or two-dimensional slices (rectangular matrices) from a three-dimensional array. However, since the range can be specified at run-time, type-checked languages may require an explicit (compile-time) notation to actually eliminate the trivial indices.

General array slicing can be implemented (whether or not built into the language) by referencing every array through a dope vector or descriptor — a record that contains the address of the first array element, and then the range of each index and the corresponding coefficient in the indexing formula. This technique also allows immediate array transposition, index reversal, subsampling, etc. For languages like C, where the indices always start at zero, the dope vector of an array with d indices has at least 1 + 2d parameters. For languages that allow arbitrary lower bounds for indices, like Pascal, the dope vector needs 1 + 3d entries.

If the array abstraction does not support true negative indices (as for example the arrays of Ada and Pascal do), then negative indices for the bounds of the slice for a given dimension are sometimes used to specify an offset from the end of the array in that dimension. In 1-based schemes, -1 generally would indicate the second-to-last item, while in a 0-based system, it would mean the very last item.

Read more about this topic:  Array Slicing

Other articles related to "details":

William Allen (VC 1879) - Details
... On 22 and 23 January 1879 at Rorke's Drift, Natal, South Africa, Corporal Allan and another man (Frederick Hitch) kept communication with the hospital open, despite being severely wounded ... Their determined conduct enabled the patients to be withdrawn from the hospital, and when incapacitated by their wounds from fighting, they continued, as soon as their wounds were dressed, to serve out ammunition to their comrades during the night ...
Erasmus Programme - Participation - Details
... There continues to be a language barrier between the countries of Europe ... Lectures may be given to ERASMUS students in the native language of the university where they are taking place or in English ...
Vehicle Register
... On the register, along with the vehicle details (make, model, engine capacity, colour, VIN, etc.) are recorded the details of the current keeper of the vehicle (name ... a registration document known as a V5C, which displays the registration details of the vehicle ... Each time any of the registration details change, if the vehicle keeper is changed, or any of the vehicle details are changed, for example, the DVLA/DVLNI has to be notified, and a new document is issued ...
Rowing At The 2000 Summer Olympics - Medal Summary - Women's Events
... Event Gold Silver Bronze Single sculls details Ekaterina Karsten Belarus (BLR) Rumyana Neykova Bulgaria (BUL) Katrin Rutschow-Stomporowski Germany (GER) Coxless ...

Famous quotes containing the word details:

    Different persons growing up in the same language are like different bushes trimmed and trained to take the shape of identical elephants. The anatomical details of twigs and branches will fulfill the elephantine form differently from bush to bush, but the overall outward results are alike.
    Willard Van Orman Quine (b. 1908)

    Patience is a most necessary qualification for business; many a man would rather you heard his story than granted his request. One must seem to hear the unreasonable demands of the petulant, unmoved, and the tedious details of the dull, untired. That is the least price that a man must pay for a high station.
    Philip Dormer Stanhope, 4th Earl Chesterfield (1694–1773)