Array model: Difference between revisions

Jump to navigation Jump to search
306 bytes added ,  09:04, 13 May 2020
Disambiguate
m (25 revisions imported: Migrate from miraheze)
(Disambiguate)
(4 intermediate revisions by 3 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 64: Line 67:
=== Numeric type coercion ===
=== Numeric type coercion ===


Most APLs, flat or nested, implicitly store simple numeric arrays as one of many [[numeric type]]s. When a numeric array is formed from numbers with different types, all numbers are converted to a common type in order to be represented as a flat array. If the hierarchy of numeric types is not strict, that is, there are some pairs of numeric types for which neither type is a subset of the other, then this coercion may affect the behavior of the numbers in the array. For example, [[J]] on a 64-bit machine uses both 64-bit integers and [[wikipedia:IEEE_754|double-precision floats]]. [[Catenate|Catenating]] the two results in an array of doubles, which will lose precision for integers whose absolute value is larger than 2<sup>53</sup>. In [[Dyalog APL]] a similar issue occurs with [[decimal float]]s and [[complex number]]s: combining the two results in an array of complex numbers, but this loses precision since Dyalog's complex numbers are stored as pairs of double-precision floats and its 128-bit decimal floats have higher precision that doubles.
Most APLs, flat or nested, implicitly store simple numeric arrays as one of many [[numeric type]]s. When a numeric array is formed from numbers with different types, all numbers are converted to a common type in order to be represented as a flat array. If the hierarchy of numeric types is not strict, that is, there are some pairs of numeric types for which neither type is a subset of the other, then this coercion may affect the behavior of the numbers in the array. For example, [[J]] on a 64-bit machine uses both 64-bit integers and [[wikipedia:IEEE_754|double-precision floats]]. [[Catenate|Catenating]] the two results in an array of doubles, which will lose precision for integers whose absolute value is larger than 2<sup>53</sup>. In [[Dyalog APL]] a similar issue occurs with [[decimal float]]s and [[complex number]]s: combining the two results in an array of complex numbers, but this loses precision since Dyalog's complex numbers are stored as pairs of double-precision floats and its 128-bit decimal floats have higher precision than doubles.


== Array characteristics ==
== Array characteristics ==
Line 96: Line 99:
* [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
{{APL features}}
* [https://www.jsoftware.com/papers/array.htm What is an Array?] by [[Roger Hui]] (in [[J]])
{{APL features}}[[Category:Arrays| ]]

Navigation menu