Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
5 user(s) are online (5 user(s) are browsing encyclopedia)

Members: 0
Guests: 5

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

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 (mathematics) to be used as a vector (mathematics).

Depending on the programming language and context, the elements of the new array may be aliasing (computing) (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, @x[2..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. ALGOL 68 introduced comprehensive multi-dimension array slicing and trimming features. Fortran 90 and Kenneth Iverson s APL programming language provide very flexible multi-dimensional array slicing, which contribute much to the languages expressive powers.