Array model: Difference between revisions

Jump to navigation Jump to search
1,889 bytes added ,  20:04, 29 September 2020
→‎External links: Add references
(→‎External links: Add references)
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
:''This page describes the array datatype as defined by array languages. For the role of arrays in [[APL syntax]], see [[Array]].''
The distinguishing feature of APL and the array language family is its focus on '''arrays'''. In most array languages the array is the only first class datatype. While this sounds like a very strict model of language design, in fact it imposes no restrictions at all: any kind of data can be treated as a [[scalar]], or array with rank 0!
The distinguishing feature of APL and the array language family is its focus on '''arrays'''. In most array languages the array is the only first class datatype. While this sounds like a very strict model of language design, in fact it imposes no restrictions at all: any kind of data can be treated as a [[scalar]], or array with rank 0!


Line 16: Line 18:


== "Array languages" without arrays ==
== "Array languages" without arrays ==
:''See also: [[Timeline of influential array languages]]''


Some languages, despite deriving from APL, do not use APL-style arrays at all! Examples include [[K]] and [[I]], which only have vectors, and [[MATLAB]], which has true multidimensional arrays but usually treats data as matrices. Languages like K are usually considered part of the array language or APL family, but may or may not be considered array languages themselves.
Some languages, despite deriving from APL, do not use APL-style arrays at all! Examples include [[K]] and [[I]], which only have vectors, and [[MATLAB]], which has true multidimensional arrays but usually treats data as matrices. Languages like K are usually considered part of the array language or APL family, but may or may not be considered array languages themselves.
Line 52: Line 53:


Flat array theory is often called "grounded" in contrast to "floating" nested array theory.
Flat array theory is often called "grounded" in contrast to "floating" nested array theory.
== Based array theory ==
Based array theory discards the principle that all data should be stored in arrays, instead defining basic types such as characters and numbers independently of arrays and arrays as a collection type—possibly one of many—that can contain any data. This model does not have any widely accepted name, with the term "based system" introduced in an [[APL Quote Quad]] paper in 1981.<ref>Randall Mercer. [https://dl.acm.org/doi/abs/10.1145/586656.586663 "A based system for general arrays"]. [[APL Quote Quad]] Volume 12, Issue 2. 1981-12.</ref> However, as it is the natural model when arrays are added to an existing programming system, it is common in array libraries such as [[NumPy]], [[wikipedia:ILNumerics|ILNumerics]], and [[wikipedia:Haskell (programming language)|Haskell]]'s [https://hackage.haskell.org/package/repa Repa], as well as the language [[Julia]]. It is used by the APL-family language [[BQN]].
=== Mutable based arrays ===
In many languages with this array style, such as NumPy and Julia, the arrays are [[wikipedia:Immutable object|mutable]], meaning that copies of an array can be made, so that one copy reflects changes made to any copy. In contrast, APL operations that appear to modify an array, like [[indexed assignment]], will only change the particular copy of the array used, and can be said to create a new array rather than change an existing one: there is no special connection between the old and modified array. Mutable arrays make it possible for an array to contain itself, by replacing one element of an existing array with the whole array. This means that more values are possible than in an immutable based array language, and that some properties of immutable arrays, such as a finite [[depth]], do not hold.


== Other features of the array model ==
== Other features of the array model ==
Line 94: Line 103:
== External links ==
== External links ==


* [http://help.dyalog.com/latest/index.htm#Language/Introduction/Variables/Arrays.htm Dyalog array model]
* [https://help.dyalog.com/latest/index.htm#Language/Introduction/Variables/Arrays.htm Dyalog array model]
* [https://chat.stackexchange.com/rooms/52405/conversation/lesson-1-introduction-to-arrays-in-apl APL Cultivation]
* [https://chat.stackexchange.com/rooms/52405/conversation/lesson-1-introduction-to-arrays-in-apl APL Cultivation]
* [https://www.sacrideo.us/tag/apl-a-day/ APL a Day] series
* [https://www.sacrideo.us/tag/apl-a-day/ APL a Day] series
* [https://www.jsoftware.com/papers/array.htm What is an Array?] by [[Roger Hui]] (in [[J]])
* [https://www.jsoftware.com/papers/array.htm What is an Array?] by [[Roger Hui]] (in [[J]])
== References ==
<references />
{{APL features}}[[Category:Arrays| ]]
{{APL features}}[[Category:Arrays| ]]

Navigation menu