4,509
edits
(Note solicitation of feedback) |
(Restore intro and comparison) |
||
Line 1: | Line 1: | ||
{| class=wikitable width=100% style=padding:"0 1em" | |||
! [[Dyalog Ltd]] requests community feedback on the array notation in the hope of ending up with a notation that is shared with other dialects.<ref>Dyalog Ltd/Adám Brudzewsky. [https://forums.dyalog.com/viewtopic.php?f=13&t=1856&p=7431#p7431 Re: Deserialise-- does it work as expected?]. Dyalog Forums. 2022-09-05.</ref> Head to the [[Array notation design considerations|design considerations]] article for details! | |||
|} | |||
{{Built-ins|Array notation|(⋄)|[⋄]}} is a way to write most [[array]]s literally, with no or minimal use of [[primitive function]]s, possibly over multiple code lines. It differs from the [[strand notation]] existing since [[APL\360]] in that it can be used to write arrays of rank greater than one. Array notation is supported in [[dzaima/APL]], [[BQN]] (using angle brackets <code>⟨⋄⟩</code> instead of round parentheses <code>(⋄)</code>), and some tools for [[Dyalog APL]], where it is planned as an eventual language feature. | |||
Array notation generally consists of a vector notation written with parentheses <source lang=apl inline>()</source>, roughly equivalent to stranding, and a high-rank notation using square brackets <source lang=apl inline>[]</source>, indicating the [[Mix]] of a vector. It also supports [[namespace]]s, using <source lang=apl inline>name:value</source> syntax in round parentheses. [[statement separator]]s must appear between elements and between [[wikipedia:name–value_pair|name–value pair]]s. | |||
== Examples == | == Examples == | ||
Line 31: | Line 35: | ||
* A ''broken'' round parenthesis creates a [[namespace]] if every diamond/line break-separated statement is a ''name-value pair''. | * A ''broken'' round parenthesis creates a [[namespace]] if every diamond/line break-separated statement is a ''name-value pair''. | ||
* A ''broken'' round parenthesis creates a [[vector]] if every diamond/line break-separated statement is a value expression. In that case, every such statement forms an [[element]] in the resulting vector. | * A ''broken'' round parenthesis creates a [[vector]] if every diamond/line break-separated statement is a value expression. In that case, every such statement forms an [[element]] in the resulting vector. | ||
* A ''broken'' square bracket creates a an [[array]] where every diamond/line break-separated statement forms a [[major cell]] in the resulting array. | * <span id=minrank1>A ''broken'' square bracket creates a an [[array]] where every diamond/line break-separated statement forms a [[major cell]] in the resulting array.[[#minrank1note|*]]<span> | ||
* <source lang=apl inline>()</source> | * <source lang=apl inline>()</source> creates a new namespace — equivalent to <source lang=apl inline>(⎕NS 0⍴⊂'')</source> | ||
* A ''name-value pair'' | * A ''name-value pair'' consists of a valid APL identifier, followed by a colon (<source lang=apl inline>:</source>) and a value expression. | ||
<span id=minrank1note>[[#minrank1|*]]</span> This rule is followed strictly in [[dzaima/APL]], while [[Dyalog APL]] considers each statement to have a rank of at least 1, even if it is a [[scalar]]. | <span id=minrank1note>[[#minrank1|*]]</span> This rule is followed strictly in [[dzaima/APL]], while [[Dyalog APL]] considers each statement to have a rank of at least 1, even if it is a [[scalar]]. | ||
Line 57: | Line 61: | ||
The project manager Acre Desktop added support for the non-namespace parts of the notation in early 2018, together with Phil Last's original namespace notation, using square brackets and assignment arrow. [[dzaima/APL]] added support for vector notation with parentheses in 2018, namespaces and function arrays in 2019, and high-rank arrays with square brackets in 2020. [[BQN]] supported lists with angle brackets (<code>⟨</code>…<code>⟩</code>) in its initial implementation in 2020; square brackets (<code>[</code>…<code>]</code>) were reserved for high-rank array notation, which was implemented in 2022. | The project manager Acre Desktop added support for the non-namespace parts of the notation in early 2018, together with Phil Last's original namespace notation, using square brackets and assignment arrow. [[dzaima/APL]] added support for vector notation with parentheses in 2018, namespaces and function arrays in 2019, and high-rank arrays with square brackets in 2020. [[BQN]] supported lists with angle brackets (<code>⟨</code>…<code>⟩</code>) in its initial implementation in 2020; square brackets (<code>[</code>…<code>]</code>) were reserved for high-rank array notation, which was implemented in 2022. | ||
{{Template:Comparison of array notations}} | |||
== Documentation == | |||
* [https://mlochbaum.github.io/BQN/doc/arrayrepr.html#array-literals BQN] (as <code>⟨⋄⟩</code>, <code>[⋄]</code>, and <code>{key⇐val⋄}</code>) | |||
* [https://www.nial-array-language.org/ndocs/NialDict2.html#bracket-comma-notation Nial] (as <code>[,]</code> for vectors) | |||
== References == | == References == | ||
<references/> | <references/> | ||
{{APL syntax}}[[Category:APL syntax]][[Category:Nested array model]] | {{APL syntax}}[[Category:APL syntax]][[Category:Nested array model]] |