Some compiled languages such as Ada and Fortran, and some scripting languages such as IDL, MATLAB, and S-Lang, have native support for vectorized operations on arrays. For example, to perform an element by element sum of two arrays, a and b to produce a third c, it is only necessary to write
c = a + b
In addition to support for vectorized arithmetic and relational operations, these languages also vectorize common mathematical functions such as sine. For example, if x is an array, then
y = sin (x)
will result in an array y whose elements are sine of the corresponding elements of the array x.
Vectorized index operations are also supported. As an example,
even=x(2::2);odd=x(::2);
is how one would use Fortran to create arrays from the even and odd entries of an array. Another common use of vectorized indices is a filtering operation. Consider a clipping operation of a sine wave where amplitudes larger than 0.5 are to be set to 0.5. Using S-Lang, this can be done by
^ abcdeXPath/XQuery has two kinds of arrays. Sequences(1,2,3) which cannot nest and in the XPath/XQuery 3.1 version arraysarray { 1,2,3} or [1,2,3] which can.
^ abcdefgThe index may be a negative number, indicating the corresponding number of places before the end of the array.
^ abcdefSlices for multidimensional arrays are also supported and defined similarly.
^ abcdSlices of the type first:last:step are also supported.
^ abcdlast or end may be a negative number, indicating to stop at the corresponding number of places before the end of the array.
^ abcMore generally, for 1-d arrays Perl and S-Lang allow slices of the formarray[indices], where indices can be a range such mentioned in footnote 2 or an explicit list of indices, e.g., '[0,9,3,4]', or a mix of both, e.g., A[[[0:3]],7,9,[11:2:-3]]].
^C# 8.0 proposed feature (as of 29 August 2019[update])
^ abThe default base index is the lowest value of the index type used
^ abcdefghijkSize can only be chosen on initialization after which it is fixed.
^ abcdeThis list is strictly comparing language features. In every language (even assembly language) it is possible to provide improved array handling via add on libraries. This language has improved array handling as part of its standard library
^ALGOL 68 arrays must be subscripted (and sliced) by type INT. However a hash function could be used to convert other types to INT. e.g. name[hash("string")]
^The indexing base can be 0 or 1 as per the System Variable ⎕IO. This value may apply to the whole "workspace", or be localized to a user-defined function or a single primitive function by use of the Variant operator (⍠).
^ abBecause C does not bound-check indices, a pointer to the interior of any array can be defined that will symbolically act as a pseudo-array that accommodates negative indices or any integer index origin.
^ abC99 allows for variable size arrays; however there is almost no compiler available to support this new feature
^ abcdeSize can only be chosen on initialization when memory is allocated on the heap, as distinguished from when it is allocated on the stack. This note need not be made for a language that always allocates arrays on the heap.
^ abcdefghijklmnopqrstuvwxAllows arrays of arrays which can be used to emulate most—but not all—aspects multi-dimensional arrays
^ abcThe base can be changed when initializing with System.Array.CreateInstance (which returns System.Array), but not when using the language syntax. Arrays with non-zero base indices are not the same type as those with zero base indices and cannot be manipulated using language syntax (the GetValue and SetValue methods must be used instead) or downcast to a specific type (T[] in C#, or T() in VB.NET), preventing breakage of code assuming base indices of zero.
^ abAllows creating fixed-size arrays in "unsafe" code, allowing enhanced interoperability with other language
^COBOL arrays may be indexed with "INDEX" types, distinct from integer types
^While COBOL only has arrays-of-arrays, array elements can be accessed with a multi-dimensional-array-like syntax, where the language automatically matches the indexes to the arrays enclosing the item being referenced
^COBOL provides a way to specify that the usable size of an array is variable, but this can never be greater than the declared maximum size, which is also the allocated size
^Most Common Lisp implementations allow checking to be selectively disabled
^ abBehaviour can be tuned via compiler switches. As in DMD 1.0 bounds are checked in debug mode and unchecked in release mode for efficiency
^FreeBASIC supports both variable array lengths and fixed length arrays. Arrays declared with no index range are created as variable-length arrays, while arrays with a declared range are created as fixed-length arrays
^Almost all Fortran implementations offer bounds checking options via compiler switches. However by default, bounds checking is usually turned off for efficiency
^While Golang's Array type is not dynamically sized, the data type Slice is dynamically-sized and is much more common in use than arrays.
^Haskell arrays (Data.Array) allow using any type which is an instance of Ix as index type. So a custom type can be defined and used as an index type as long as it instances Ix. Also, tuples of Ix types are also Ix types; this is commonly used to implement multi-dimensional arrays
^ abcdIn these languages, one can access or write to an array index greater than or equal to the length of the array, and the array will implicitly grow to that size. This may appear at first as if the bounds are not checked; however, the bounds are checked to decide to grow the array, and you do not have unsafe memory access like you do in C.
^ abBy specifying a base index, arrays at an arbitrary base can be created. However, by default, Lua's length operator does not consider the base index of the array when calculating the length. This behavior can be changed via metamethods.
^At least 2 dimensions (scalar numbers are 1×1 arrays, vectors are 1×n or n×1 arrays).
^Standard Perl array data types do not support vectorized operations as defined here. However, the Perl Data Language extension adds array objects with this ability.
^ abcPHP's "arrays" are associative arrays. You can use integers and strings as the keys (indexes); floats can also be used as the key but are truncated to integers. There is not really any "base index" or "bounds"
^Size can be chosen when the array is declared, or when it is allocated, after which it is fixed.
^The standard Python array type, list, does not support vectorized operations as defined here. However, the numpy extension adds array objects with this ability
^The class Array is fixed-size, but OrderedCollection is dynamic
^ abMicrosoft QBASIC, QuickBASIC, Visual Basic, and VBA all had/have the ability to specify Option Base 1, which caused all arrays in the module to default starting at 1 instead of 0. Support for Option Base was phased out in Visual Basic (.NET). In various Microsoft BASIC implementations, arrays can be DIMensioned using to to specify the minimum and maximum index values (e.g. DIM MyArray(2 to 50) AS STRING would have the first index at 2 instead of the default).