Array Slicing

In computer programming, array slicing is an operation that extracts certain elements from an array and packages them as another array, possibly with different number of indices and different index ranges. Two common examples are extracting a substring from a string of characters (e.g. "kipe" from "wikipedia"), and extracting a row (or a column) of a rectangular matrix to be used as a vector. Depending on the language and context, the elements of the new array may be aliased to (i.e., share memory with) those of the original array.

Slicing vectors and strings

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 index 2 to 5, we get (7, 3, 8, 6). In the Perl programming language, which allows arrays to be sliced easily, if we have
  @x = (2, 5, 7, 3, 8, 6, 4, 1) 
as above,
  @x2..5 
will represent the sliced array (7, 3, 8, 6).

History

The concept of slicing was surely known even before the invention of compilers. Slicing as a language feature probably started with the FORTRAN, more as a consequence of non-existent type and range checking than by design. Fortran 90 and Kenneth Iverson's APL provide very flexible multi-dimensional array slicing, which contribute much to the languages' expressive powers.

 

<< PreviousWord BrowserNext >>
booker (professional wrestling)
chaplain tappman
michael brecker
blading (professional wrestling)
janjaweed
betdaq
bernd and hilla becher
6to4
james tuchet, 5th baron audley
squared circle (professional wrestling)
communities in achaia
fuck (band)
guimares
conway's lux method for magic squares
list of norwegian television series
wonder what's next
1978 hawaii state constitutional convention
card (professional wrestling)
buggane
brokopondo
bom jesus do monte
carlos enrique daz de len
hepa
chick gandil
total station
james benning
metanephridium
jeffrey miller
fuse (electrical)
fuse (explosives)
fuse (television)
dragon rouge
field upgradeable systems environment
young tableau
shawsheen village, massachusetts
general admiral
mutant enemy productions
triumf
spinneret
pozzolanic ash
rulers of auvergne
dorrit hoffleit
david mallett
bob merrill