Consistent Extensions in NARS2000: Difference between revisions

From NARS2000
Jump to navigationJump to search
 
(61 intermediate revisions by 2 users not shown)
Line 2: Line 2:


== Language Features ==
== Language Features ==
* Sink:  monadic left arrow (<apll>←R</apll>) suppresses the display of <apll>R</apll>.
* [[Sink]]:  monadic left arrow (<apll>←R</apll>) suppresses the display of <apll>R</apll>.
* Unified index reference, assignment, and modify assignment (<apll>R[L]</apll>, <apll>R[L]←A</apll>, and <apll>R[L]<i>f</i>←A</apll>):  these three forms all allow both Reach and Scatter indexing — that is, if <apll>L⊃R</apll> is valid, it is equivalent to <apll>⊃R[⊂L]</apll>, and if <apll>L⌷R</apll> is valid, it is equivalent to <apll>R[⊃∘.,/L]</apll> Reach and Scatter indexing may appear together within a single instance of <apll>R[L]</apll>, <apll>R[L]←A</apll>, and <apll>R[L]<i>f</i>←A</apll>.
* [[Indexing|Unified index reference, assignment, and modify assignment]] (<apll>R[L]</apll>, <apll>R[L]←A</apll>, and <apll>R[L]<i>f</i>←A</apll>):  these three forms all allow both Reach and Scatter indexing — that is,
* Dyadic operator jot (<apll><i>f</i>∘<i>g</i></apll>) (composition) is used to join two functions or a function and a variable to produce a derived function (e.g., <apll>,∘⍋∘⍋∘,</apll>) which is applied as a single function.  For example, the function <apll>*∘2</apll> when applied monadically, squares its argument.
** if <apll>L⊃R</apll> is valid, it is equivalent to <apll>⊃R[⊂L]</apll>, and
* Monadic operator null (<apll><i>f</i>⊙</apll>):  To aid in resolving ambiguities with slash/slope as function/operator, use this operator.  It passes through all functions as functions, and forces the symbols slash/slope to be functions rather than operators.  For example, use <apll>(/⊙)/3 4</apll> instead of <apll>(/)/3 4</apll>.
** if <apll>L⊃¨⊂R</apll> is valid, it is equivalent to <apll>R[L]</apll>, and
* Monadic iota (<apll>⍳R</apll>) extended to negative indices.  For example, in origin-0, <apll>⍳¯3</apll> returns <apll>¯3 ¯2 ¯1</apll>.
** if <apll>L⌷R</apll> is valid, it is equivalent to <apll>R[⊃∘.,/L]</apll>, and
* Monadic iota (<apll>⍳R</apll>) extended to length > 1 vector right arguments returns an array of indices whose shape is that of the right argument (via an internal magic function).
** if <apll>L⌷¨⊂R</apll> is valid, it is equivalent to <apll>⊂¨R[⊂¨L]</apll>
* Dyadic iota (<apll>L⍳R</apll>) extended to rank > 1 left arguments returns an array of vector indices to the left argument (via an internal magic function).
:Reach and Scatter indexing may appear together within a single instance of <apll>R[L]</apll>, <apll>R[L]←A</apll>, and <apll>R[L]<i>f</i>←A</apll>.
* Index reference, assignment, modify assignment, squad, and pick (<apll>R[L]</apll>, <apll>R[L]←A</apll>, <apll>R[L]<i>f</i>←A</apll>, <apll>L⌷R</apll>, and <apll>L⊃R</apll>) are each extended to negative values in <apll>L</apll>.  That is, if the largest allowed value is <apll>N</apll>, then the allowable range for the values in <apll>L</apll>  is <apll>1 ¯1[1]-N</apll> to <apll>N</apll>, inclusive.  For example, <apll>A</apll>, <apll>A[⍳⍴A]</apll>, and <apll>A[⍳-⍴A]</apll> are all identical for any array <apll>A</apll> in either origin.
* [[Rank|Dyadic operator dieresis-jot]] (<apll><i>f</i>⍤[X] Y</apll>) (rank) is used to apply a function to (monadic) or between (dyadic) cells of the argument(s).
* Monadic and dyadic domino (<apll>⌹R</apll> and <apll>L⌹R</apll>) — matrix inverse/divide extended to use Moore-Penrose pseudo-inverse algorithm via Singular Value Decomposition.
* [[Compose|Dyadic operator jot]] (<apll><i>f</i>∘<i>g</i></apll>) (compose) is used to join two functions or a function and a variable to produce a derived function (e.g., <apll>,∘⍋∘⍋∘,</apll>) which is applied as a single function.  For example, the function <apll>*∘2</apll> when applied monadically, squares its argument.
* [[Null|Monadic operator null]] (<apll><i>f</i>⊙</apll>):  To aid in resolving ambiguities with slash/slope as function/operator, use this operator.  It passes through all functions as functions, and forces the symbols slash/slope to be functions rather than operators.  For example, use <apll>(/⊙)/3 4</apll> instead of <apll>(/)/3 4</apll>.
* [[Partitioned_Enclose|Partitioned Enclose]] (<apll>L⊂[X] R</apll>):  Partition <apll>R</apll> along the <apll>X</apll> axis according to <apll>L</apll>.
* [[Index_Generator|Monadic iota]] (<apll>⍳R</apll>) extended to negative indices.  For example, in origin-0, <apll>⍳¯3</apll> returns <apll>¯3 ¯2 ¯1</apll>.
* [[Index_Generator|Monadic iota]] (<apll>⍳R</apll>) extended to length > 1 vector right arguments returns an array of indices whose shape is that of the right argument.
* [[Index_Of|Dyadic iota]] (<apll>L⍳R</apll>) extended to rank > 1 left arguments returns an array of vector indices to the left argument.
* [[Indexing|Index reference, assignment, modify assignment, squad, transpose, pick, and the axis operator]] (<apll>R[L]</apll>, <apll>R[L]←A</apll>, <apll>R[L]<i>f</i>←A</apll>, <apll>L⌷R</apll>, <apll>L⍉R</apll>, <apll>L⊃R</apll>, and <apll><i>f</i>[L]</apll>) are each extended to negative values in <apll>L</apll>.  That is, if the largest allowed value is <apll>N</apll>, then the allowable range for the values in <apll>L</apll>  is <apll>1 ¯1[1]-N</apll> to <apll>N</apll>, inclusive.  For example, <apll>A</apll>, <apll>A[⍳⍴A]</apll>, and <apll>A[⍳-⍴A]</apll> are all identical for any array <apll>A</apll> in either origin, as are <apll>A</apll>, <apll>(⍳⍴⍴A)⍉A</apll>, and <apll>(⍳-⍴⍴A)⍉A</apll>.
* [[Matrix_Inverse/Divide|Monadic and dyadic domino]] (<apll>⌹R</apll> and <apll>L⌹R</apll>) — matrix inverse/divide extended to use Moore-Penrose pseudo-inverse algorithm via Singular Value Decomposition.
* Prototypes for all primitive functions and operators.
* Prototypes for all primitive functions and operators.
* Out of range numeric assignments to <apll>⎕PP</apll> and <apll>⎕PW</apll> are set to the value in the allowable range nearest the ceiling of the given number. For example, if <apll>⎕PP</apll> is set to <apll>23.7</apll>, that value is rounded down to <apll>17</apll>, the largest value that system variable may assume.
* Jot may be used as either operand to a user-defined operator in which case the name associated with the jot inside the operator is undefined, that is, <apll>⎕NC</apll> on the name returns <apll>0</apll>.
* Assigning a simple empty vector to a scalar system variable (<apll>⎕CT</apll>, <apll>⎕IO</apll>, <apll>⎕PP</apll>, <apll>⎕PW</apll>, or <apll>⎕RL</apll>) assigns the system default value to the variable.
* Generalized Identity Functions for reduction and inner product.
* Selective assignment, e.g. <apll>(1 1⍉M)←0</apll>.
* [[Scalar_System_Variables|Out of range numeric assignments]] to one of these system variables (<apll>⎕CT</apll>, <apll>⎕DT</apll>, <apll>⎕FPC</apll>, <apll>⎕IC</apll>, <apll>⎕IO</apll>, <apll>⎕PP</apll>, <apll>⎕PW</apll>, or <apll>⎕RL</apll>) is set to the value in the allowable range nearest the ceiling of the given number. For example, if <apll>⎕FPC</apll> is set to <apll>23.7</apll>, that value is rounded up to <apll>53</apll>, the smallest value that system variable may assume.
* [[Scalar_System_Variables|Assigning a simple empty vector]] to one of these system variables (<apll>⎕CT</apll>, <apll>⎕DT</apll>, <apll>⎕FPC</apll>, <apll>⎕IC</apll>, <apll>⎕IO</apll>, <apll>⎕PP</apll>, <apll>⎕PW</apll>, or <apll>⎕RL</apll>) assigns the system default value to the variable.
* [[Find]]: dyadic epsilon underbar (<apll>L⍷R</apll>) using the Knuth-Morris-Pratt string searching algorithm.
* [[Reshape]]: (<apll>L⍴R</apll>) is extended to allow a non-empty Reshape of an empty in which case the right argument fill element is used, e.g., <apll>2 3⍴⍬</apll>.
* [[Mismatch]]: Primitive dyadic not equal underbar (<apll>L≢R</apll>) equivalent to <apll>~L≡R</apll>.
* [[Tally]]: Primitive monadic not equal underbar (<apll>≢R</apll>) which is equivalent to <apll>⍬⍴(⍴R),1</apll>.
* [[Indices]]: Primitive monadic iota underbar (<apll>⍸R</apll>) which is equivalent to <apll>(,R)/,⍳⍴1/R</apll>.
* [[Array Lookup]]: Primitive dyadic iota underbar (<apll>L⍸R</apll>) which for matrices looks up the rows of <apll>R</apll> in the rows of <apll>L</apll>.  In general, this function looks up the trailing subarrays of <apll>R</apll> in the vector of trailing subarrays of <apll>L</apll>, and is equivalent to <apll>(⊂⍤¯1 L)⍳⊂⍤(¯1+⍴⍴L) R</apll>.
* [[Type]]: Primitive monadic function down tack (<apll>⊤R</apll>) (Type).
* [[Composition]]: Primitive dyadic operator dieresis circle (<apll>L f⍥g R</apll>) (Composition).
* [[Root]]: Primitive monadic and dyadic functions (<apll>√R</apll> and <apll>L√R</apll>) (Root).
* [[Sets]]:  Primitive dyadic functions (<apll>L§R</apll>, <apll>L⊆R</apll>, and <apll>L⊇R</apll>) (Set functions).
* [[Primes]]: Primitive monadic and dyadic functions pi (<apll>πR</apll> and <apll>LπR</apll>) (Prime decomposition and Number-theoretic functions).
* [[Sequence]]: Primitive dyadic function (<apll>L..R</apll>) (Sequence).
* [[Variant]]:  Primitive dyadic operator quad colon (<apll>f⍠V R</apll> and <apll>L f⍠V R</apll>) (Variant).
* [[Anonymous Functions/Operators/Hyperators]]: one-line grouping of one or more statements all enclosed in braces such as <apll>{(+⌿⍵)÷≢⍵}</apll>.
* [[Determinant]]:  Primitive dyadic operator (<apll>f.g R</apll>) (Determinant Operator).
* [[Convolution]]:  Primitive dyadic operator (<apll>L f⍡g R</apll>) (Convolution Operator).
<!-- * Selective assignment, e.g. <apll>(1 1⍉M)←0</apll>. -->
* New System Variables
* New System Variables
** <apll>⎕FC</apll> (Format Control)
** <apll>⎕DT</apll> ([[System_Variable_DT|Distribution Type]])
** <apll>⎕IC</apll> (Indeterminate Control)
** <apll>⎕FC</apll> ([[System_Variable_FC|Format Control]])
** <apll>⎕FPC</apll> ([[System_Variable_FPC|Floating Point Control]])
** <apll>⎕IC</apll> ([[System_Variable_IC|Indeterminate Control]])
* New or Changed System Functions
* New or Changed System Functions
** <apll>⎕AV</apll> (Atomic Vector) &mdash; has all UCS-2 Unicode characters (65,536 in length)
** <apll>⎕A</apll> ([[System_Function_A|Uppercase English Alphabet]]) &mdash; returns the 26-character uppercase English alphabet.
** <apll>L ⎕CR R</apll> (Canonical Representation) &mdash; <apll>1=|L</apll> (nested vector of character vectors) and <apll>2=|L</apll> (character matrix); <apll>L&lt;0</apll> returns representations of internal magic functions
** <apll>⎕AT</apll> ([[System_Function_AT|Object Attributes]]) &mdash; returns various attributes (Valence, Fix Time, Execution Properties, and Size) of an object
** <apll>⎕DM</apll> (Diagnostic Message)
** <apll>⎕AV</apll> ([[System_Function_AV|Atomic Vector]]) &mdash; has all UCS-2 Unicode characters (65,536 in length)
** <apll>⎕DR R</apll> and <apll>L ⎕DR R</apll> (Data Representation)
** <apll>L ⎕CR R</apll> ([[System_Function_CR|Canonical Representation]]) &mdash; <apll>L=1</apll> (nested vector of character vectors) and <apll>L=2</apll> (character matrix)
** <apll>⎕ERROR R</apll> (Signal Error)
** <apll>⎕DM</apll> ([[System_Function_DM|Diagnostic Message]])
** <apll>⎕MF R</apll> (Monitor Function)
** <apll>⎕DR R</apll> and <apll>L ⎕DR R</apll> ([[System_Function_DR|Data Representation]])
** <apll>⎕NL R</apll> (Name List) &mdash; <apll>R=8</apll> lists Magic Functions.
** <apll>L ⎕EA R</apll> ([[System_Function_EA|Execute Alternate]])
** <apll>⎕SIZE R</apll> (Object Size)
** <apll>⎕EC R</apll> ([[System_Function_EC|Execute Controlled]])
** <apll>⎕SYSID</apll> (System Identification)
** <apll>⎕EM</apll> ([[System_Function_EM|Event Message]])
** <apll>⎕SYSVER</apll> (System Version)
** <apll>⎕ERROR R</apll> ([[System_Function_ERROR|Signal Error]])
** <apll>⎕TC</apll> and other related <apll>⎕TC</apll>''xxx'' (Terminal Character)
** <apll>⎕ES R</apll> and <apll>L ⎕ES R</apll> ([[System_Function_ES|Event Simulate]])
** <apll>L ⎕TF R</apll> (Transfer Form) &mdash; <apll>1=|L</apll> (Type 1 Transfer Form) and <apll>2=|L</apll> (Type 2 Transfer Form); <apll>L&lt;0</apll> interprets <apll>R</apll> and the result as Unicode characters; <apll>L&gt;0</apll> interprets them as APL2 characters  
** <apll>⎕ET</apll> ([[System_Function_ET|Event Type]])
** <apll>⎕TYPE R</apll> (Object Prototype)
** <apll>⎕FMT R</apll> ([[System Function FMT#Monadic_Function|Format arrays within Boxes]])
** <apll>⎕UCS R</apll> (Unicode Character Set)
** <apll>L ⎕FMT R</apll> ([[System Function FMT#Dyadic_Function|Format arrays using Format Phrases]])
** <apll>⎕MF R</apll> ([[System_Function_MF|Monitor Function]])
** <apll>⎕Nxxxx</apll> ([[System_Function_Native_Files|Native File Functions]])
** <apll>⎕NC R</apll> ([[System_Function_NC|Name Class]]) &mdash; returns <apll>21</apll> through <apll>24</apll> for System labels, (Unused), Magic functions, and Magic operators.
** <apll>⎕NL R</apll> ([[System_Function_NL|Name List]]) &mdash; <apll>R=21</apll> through <apll>24</apll> lists System labels, (Unused), Magic functions, and Magic operators.
** <apll>⎕STOP</apll> ([[System_Function_STOP|Query/Set STOP Property On Functions]])
** <apll>⎕SYSID</apll> ([[System_Function_SYSID|System Identification]])
** <apll>⎕SYSVER</apll> ([[System_Function_SYSVER|System Version]])
** <apll>⎕TC</apll> and other related <apll>⎕TC</apll>''xxx'' ([[System_Function_TC|Terminal Control]])
** <apll>L ⎕TF R</apll> ([[System_Function_TF|Transfer Form]]) &mdash; <apll>1=|L</apll> (Type 1 Transfer Form) and <apll>2=|L</apll> (Type 2 Transfer Form); <apll>L&lt;0</apll> interprets <apll>R</apll> and the result as Unicode characters; <apll>L&gt;0</apll> interprets them as APL2 characters
** <apll>⎕TRACE</apll> ([[System_Function_TRACE|Query/Set TRACE Property On Functions]])
** <apll>⎕UCS R</apll> ([[System_Function_UCS|Unicode Character Set]])
** <apll>⎕VR R</apll> ([[System Function VR|Visual Representation]])
** <apll>⎕WA</apll> ([[System Function WA|Workspace Available]])
* New Datatypes
* New Datatypes
** 2-byte Characters (Unicode, that is, UCS-2)
** 2-byte Characters (Unicode, that is, UCS-2)
** 64-bit Integers
** 64-bit Integers
** APAs (Arithmetic Progression Arrays) (e.g., <apll>2 3 4⍴⍳24</apll>)
** APAs (Arithmetic Progression Arrays) (e.g., <apll>2 3 4⍴⍳24</apll> and <apll>1E12⍴1</apll>)
** ± Infinity (e.g., <apll>∞</apll> for infinity and <apll>¯∞</apll> for negative infinity) — considerable development work needs to be done to this feature to handle the many special cases
** ± Infinity (e.g., <apll>∞</apll> for infinity and <apll>¯∞</apll> for negative infinity) — considerable development work needs to be done to this feature to handle the many special cases
** Rational numbers (e.g., <apll>1r3</apll> and <apll>12345x</apll>)
** Variable precision floating point numbers (e.g., <apll>1.234v</apll> and <apll>12v</apll>)


== Miscellaneous Syntax ==
== Miscellaneous Syntax ==
* Strand Assignment:  A sequence of names enclosed in parentheses can be assigned to.  For example, <apll>(A B)←1 2</apll> is the same as <apll>A←1</apll> followed by <apll>B←2</apll>.
* [[Strand_Assignment|Strand Assignment]]:  A sequence of names enclosed in parentheses can be assigned to.  For example, <apll>(A B)←1 2</apll> is the same as <apll>A←1</apll> followed by <apll>B←2</apll>.
* Modify Assignment:  An arbitrary (primitive or user-defined) dyadic function may appear immediately to the left of an assignment arrow.  For example, <apll>A<i>f</i>←1</apll> is the same as <apll>A←A<i>f</i> 1</apll>, and <apll>A[L]<i>f</i>←1</apll> is the same as <apll>A[L]←A[L]<i>f</i> 1</apll>.
* [[Modified_Assignment|Modified Assignment]]:  An arbitrary (primitive or user-defined) dyadic function may appear immediately to the left of an assignment arrow.  For example, <apll>A<i>f</i>←1</apll> is the same as <apll>A←A<i></i> 1</apll>, and <apll>A[L]<i>f</i>←1</apll> is the same as <apll>A[L]←A[L]<i></i> 1</apll>.
* Modify Strand Assignment:  An arbitrary (primitive or user-defined) dyadic function may appear immediately to the left of the assignment arrow used in Strand Assignment (e.g. <apll>(A B)<i>f</i>←1 2</apll> is the same as <apll>A←A<i>f</i> 1</apll> followed by <apll>B←B<i>f</i> 2</apll>).
* [[Modify_Strand_Assignment|Modify Strand Assignment]]:  An arbitrary (primitive or user-defined) dyadic function may appear immediately to the left of the assignment arrow used in Strand Assignment (e.g. <apll>(A B)<i>f</i>←1 2</apll> is the same as <apll>A←A<i>f</i> 1</apll> followed by <apll>B←B<i>f</i> 2</apll>).
* Function/operator assignment:  A primitive function, operator, or derived function may be assigned to any available name (e.g., <apll>F←⍋</apll>, or <apll>F←¨</apll>, or <apll>F←∘</apll>, or <apll>F←+.×</apll>).
* [[Function/Operator/Hyperator_Assignment|Function/operator/hyperator assignment]]:  A primitive function, operator, or derived function may be assigned to any available name (e.g., <apll>F←⍋</apll>, or <apll>F←¨</apll>, or <apll>F←∘</apll>, or <apll>F←+.×</apll>).
* Axis operator with primitive scalar dyadic functions:  The axis operator indicates how the coordinates of the lower rank argument map to the coordinates of the higher rank argument.  For example, <apll>(1 2+[1] 2 3⍴R</apll> is equivalent to <apll>(⍉3 2⍴1 2)+2 3⍴R</apll>.
* [[Axis|Axis operator with primitive scalar dyadic functions]]:  The axis operator indicates how the coordinates of the lower rank argument map to the coordinates of the higher rank argument.  For example, <apll>(1 2+[1] 2 3⍴R</apll> is equivalent to <apll>(⍉3 2⍴1 2)+2 3⍴R</apll>.
* Axis operator with primitive scalar dyadic functions:  The order of the values in the axis operator brackets is significant.  For example, <apll>(2 3⍴L)+[1 2] 2 3 4⍴R</apll> and <apll>(⍉2 3⍴L)+[2 1] 2 3 4⍴R</apll> are identical.
* [[Axis|Axis operator with primitive scalar dyadic functions]]:  The order of the values in the axis operator brackets is significant.  For example, <apll>(2 3⍴L)+[1 2] 2 3 4⍴R</apll> and <apll>(⍉2 3⍴L)+[2 1] 2 3 4⍴R</apll> are identical.
* Axis operator with the dyadic derived function from the Each operator:  As with primitive scalar dyadic functions, the axis operator indicates how the coordinates of the lower rank argument map to the coordinates of the higher rank argument.  For example,  <apll>(2 3⍴L)⍴¨[1 2] 2 3 4⍴R</apll> is equivalent to <apll>(3 1 2⍉4⌿1 2 3⍴L)⍴¨2 3 4⍴R</apll>.
* [[Axis|Axis operator with the dyadic derived function from the Each operator]]:  As with primitive scalar dyadic functions, the axis operator indicates how the coordinates of the lower rank argument map to the coordinates of the higher rank argument.  For example,  <apll>(2 3⍴L)⍴¨[1 2] 2 3 4⍴R</apll> is equivalent to <apll>(3 1 2⍉4⌿1 2 3⍴L)⍴¨2 3 4⍴R</apll>.
* Axis operator to Ravel:  The order of the values in the axis operator brackets is significant, and may transpose coordinates in the right argument before mapping the values to the result.  For example, <apll>,[2 1] R</apll> and <apll>,[1 2] R</apll> are both valid and have the same shape and values but, in general, the values are in a different order.
* [[Axis|Axis operator to Ravel]]:  The order of the values in the axis operator brackets is significant, and may transpose coordinates in the right argument before mapping the values to the result.  For example, <apll>,[2 1] R</apll> and <apll>,[1 2] R</apll> are both valid and have the same shape and values but, in general, the values are in a different order.
* Axis operator with user-defined functions/operators:  A user-defined function/operator may be sensitive to the axis operator in the same way various primitive functions and operators are.  For example, <apll>FOO[2 3] R</apll> is valid if the function header is defined as <apll>∇ Z←FOO[X] R</apll>.
* [[Axis|Axis operator with user-defined functions/operators/hyperators]]:  A user-defined function/operator/hyperator may be sensitive to the axis operator in the same way various primitive functions and operators are.  For example, <apll>FOO[2 3] R</apll> is valid if the function header is defined as <apll>∇ Z←FOO[X] R</apll>.
* Axis operator values may be negative. That is, if the largest allowed value is <apll>N</apll>, then the allowable range for axis operator values is <apll>1 ¯1[1]-N</apll> to <apll>N</apll>, inclusive.
* [[Axis|Axis operator values may be negative]]:  That is, if the largest allowed value is <apll>N</apll>, then the allowable range for axis operator values is <apll>1 ¯1[1]-N</apll> to <apll>N</apll>, inclusive.
* Strand left and right arguments and result to user-defined functions/operators along with optional left argument may be specified:  For example, a strand right argument may be specified as <apll>∇ Z←FOO (R<sub>1</sub> R<sub>2</sub> R<sub>3</sub> R<sub>4</sub>)</apll> or, more fully, with a non-displayable result and strands used in all of the result, left, and right arguments with an optional left argument may be specified as <apll>∇ (Z<sub>1</sub> Z<sub>2</sub>)←{L<sub>1</sub> L<sub>2</sub> L<sub>3</sub>} (LO OP2[X] RO) (R<sub>1</sub> R<sub>2</sub> R<sub>3</sub> R<sub>4</sub>)</apll>.
* [[User-Defined_Functions/Operators/Hyperators|Strand left and right arguments and result to user-defined functions/operators]] along with optional left argument may be specified:  For example, a strand right argument may be specified as <apll>∇ Z←FOO (R<sub>1</sub> R<sub>2</sub> R<sub>3</sub> R<sub>4</sub>)</apll> or, more fully, with a non-displayable result and strands used in all of the result, left, and right arguments with an optional left argument may be specified as <apll>∇ (Z<sub>1</sub> Z<sub>2</sub>)←{L<sub>1</sub> L<sub>2</sub> L<sub>3</sub>} (LO OP2[X] RO) (R<sub>1</sub> R<sub>2</sub> R<sub>3</sub> R<sub>4</sub>)</apll>.
* Note that braces are '''required''' to surround the left argument of an ambivalent function as in <apll>∇ Z←{L} FOO R</apll> — Is this an '''inconsistent''' extension?
* Note that braces are '''required''' to surround the left argument of an ambivalent function as in <apll>∇ Z←{L} FOO R</apll>.
* The result of a user-defined function/operator may be marked as non-displayable by enclosing it in braces, as in <apll>∇ {Z}←FOO R</apll>. If the result part of the header consists of multiple names, either <apll>∇ {Z<sub>1</sub> Z<sub>2</sub>}←FOO R</apll> or <apll>∇ ({Z<sub>1</sub> Z<sub>2</sub>})←FOO R</apll> or <apll>∇ {(Z<sub>1</sub> Z<sub>2</sub>)}←FOO R</apll> may be used to mark the result as non-displayable.
* [[User-Defined_Functions/Operators/Hyperators|The result of a user-defined function/operator/hyperator]] may be marked as non-displayable by enclosing it in braces, as in <apll>∇ {Z}←FOO R</apll>. If the result part of the header consists of multiple names, either <apll>∇ {Z<sub>1</sub> Z<sub>2</sub>}←FOO R</apll> or <apll>∇ ({Z<sub>1</sub> Z<sub>2</sub>})←FOO R</apll> or <apll>∇ {(Z<sub>1</sub> Z<sub>2</sub>)}←FOO R</apll> may be used to mark the result as non-displayable.
* User-defined function/operator prototype line label (<apll>⎕PROTOTYPE:</apll>):  When the user-defined function/operator is called to produce a prototype, this entry point is where execution of the function starts.
* [[Control_Structures|Control structures]] on one line or split across multiple lines (e.g., <apll>:for I :in ⍳N ⋄ ... ⋄ :endfor</apll>).
* Control structures on one line or split across multiple lines (e.g., <apll>:for I :in ⍳N ⋄ ... ⋄ :endfor</apll>).
* [[Point_Notation|Point Notation]] (<b>Base</b>, <b>Euler</b>, <b>Pi</b>, and <b>Gamma</b>) are extensions to the familiar <b>Decimal</b> and <b>Exponential</b> Point Notation for entering numeric constants.  For example, the numeric constant <apll>16bffff</apll> is a shorthand for calculating <apll>16⊥15 15 15 15</apll>.
* [[Trains]]:  e.g., <apll>avg←(+⌿ ÷ ≢)</apll> applies the functions to its argument(s) in a particular way (in this case, to compute the average of a numeric vector).
* [[System Labels]]:  <apll>⎕PRO</apll>, <apll>⎕ID</apll>, and <apll>⎕MS</apll> in user-defined functions/operators.


== System commands ==
== System commands ==
* <apll>)CLOSE</apll>
* [[System Command CLOSE|<apll>)CLOSE</apll>]]
* <apll>)EDIT</apll>
* [[System Command COPY|<apll>)COPY</apll>]]
* <apll>)EXIT</apll>
* [[System Command EDIT|<apll>)EDIT</apll>]]
* <apll>)NEWTAB</apll>
* [[System Command EXIT|<apll>)EXIT</apll>]]
* <apll>)RESET</apll>
* [[System Command IN|<apll>)IN</apll>]]
* [[System Command INASCII|<apll>)INASCII</apll>]]
* [[System Command NEWTAB|<apll>)NEWTAB</apll>]]
* [[System Command EXIT|<apll>)OFF</apll>]]
* [[System Command OUT|<apll>)OUT</apll>]]
* [[System Command RESET|<apll>)RESET</apll>]]
* [[System Command ULIB|<apll>)ULIB</apll>]]


== Session Manager ==
== Session Manager ==
* Function editor:  this feature may be invoked by typing <apll>∇</apll> by itself, or <apll>∇</apll> followed by a name, or <apll>)EDIT</apll> by itself, or <apll>)EDIT</apll> followed by a name, or by double-right-clicking on a function name in the session manager or function editor windows
* [[Function_Editing|Function editor]]:  this feature may be invoked by typing <apll>∇</apll> by itself, or <apll>∇</apll> followed by a name, or <apll>)EDIT</apll> by itself, or <apll>)EDIT</apll> followed by a name, or by double-right-clicking on a function name in the session manager or function editor windows
* Multiple workspaces may be open at the same time and switched between via Tabs
* [[Session_Manager|Multiple workspaces]] may be open at the same time and switched between via Tabs
* Workspaces are saved as plain text ASCII files
* [[Initialization_and_Workspace_Files#Workspace_Files|Workspaces]] are saved as plain text ASCII files
* All variable names are two-byte characters (Unicode, that is, UCS-2)
* All variable names are two-byte characters (Unicode, that is, UCS-2)
* Array rank and dimension limit of 64 bits
* Array rank and dimension limit of 64 bits
* Multilevel Undo in function editing
* [[Session_Manager|Multilevel Undo]] in function editing
* Undo buffer saved with function for reuse on next edit
* Undo buffer saved with function for reuse on next edit
[[Category:Features]]

Latest revision as of 16:20, 13 October 2019

The following features are considered consistent extensions to the Extended APL Standard in that they replace error-producing behavior with non-error-producing behavior. Note that Extended APL Standard wants you to know that the use of a consistent extension prevents a program from conforming with the Standard.

Language Features

  • Sink: monadic left arrow (←R) suppresses the display of R.
  • Unified index reference, assignment, and modify assignment (R[L], R[L]←A, and R[L]f←A): these three forms all allow both Reach and Scatter indexing — that is,
    • if L⊃R is valid, it is equivalent to ⊃R[⊂L], and
    • if L⊃¨⊂R is valid, it is equivalent to R[L], and
    • if L⌷R is valid, it is equivalent to R[⊃∘.,/L], and
    • if L⌷¨⊂R is valid, it is equivalent to ⊂¨R[⊂¨L]
Reach and Scatter indexing may appear together within a single instance of R[L], R[L]←A, and R[L]f←A.
  • Dyadic operator dieresis-jot (f⍤[X] Y) (rank) is used to apply a function to (monadic) or between (dyadic) cells of the argument(s).
  • Dyadic operator jot (fg) (compose) is used to join two functions or a function and a variable to produce a derived function (e.g., ,∘⍋∘⍋∘,) which is applied as a single function. For example, the function *∘2 when applied monadically, squares its argument.
  • Monadic operator null (f): To aid in resolving ambiguities with slash/slope as function/operator, use this operator. It passes through all functions as functions, and forces the symbols slash/slope to be functions rather than operators. For example, use (/⊙)/3 4 instead of (/)/3 4.
  • Partitioned Enclose (L⊂[X] R): Partition R along the X axis according to L.
  • Monadic iota (⍳R) extended to negative indices. For example, in origin-0, ⍳¯3 returns ¯3 ¯2 ¯1.
  • Monadic iota (⍳R) extended to length > 1 vector right arguments returns an array of indices whose shape is that of the right argument.
  • Dyadic iota (L⍳R) extended to rank > 1 left arguments returns an array of vector indices to the left argument.
  • Index reference, assignment, modify assignment, squad, transpose, pick, and the axis operator (R[L], R[L]←A, R[L]f←A, L⌷R, L⍉R, L⊃R, and f[L]) are each extended to negative values in L. That is, if the largest allowed value is N, then the allowable range for the values in L is 1 ¯1[1]-N to N, inclusive. For example, A, A[⍳⍴A], and A[⍳-⍴A] are all identical for any array A in either origin, as are A, (⍳⍴⍴A)⍉A, and (⍳-⍴⍴A)⍉A.
  • Monadic and dyadic domino (⌹R and L⌹R) — matrix inverse/divide extended to use Moore-Penrose pseudo-inverse algorithm via Singular Value Decomposition.
  • Prototypes for all primitive functions and operators.
  • Jot may be used as either operand to a user-defined operator in which case the name associated with the jot inside the operator is undefined, that is, ⎕NC on the name returns 0.
  • Generalized Identity Functions for reduction and inner product.
  • Out of range numeric assignments to one of these system variables (⎕CT, ⎕DT, ⎕FPC, ⎕IC, ⎕IO, ⎕PP, ⎕PW, or ⎕RL) is set to the value in the allowable range nearest the ceiling of the given number. For example, if ⎕FPC is set to 23.7, that value is rounded up to 53, the smallest value that system variable may assume.
  • Assigning a simple empty vector to one of these system variables (⎕CT, ⎕DT, ⎕FPC, ⎕IC, ⎕IO, ⎕PP, ⎕PW, or ⎕RL) assigns the system default value to the variable.
  • Find: dyadic epsilon underbar (L⍷R) using the Knuth-Morris-Pratt string searching algorithm.
  • Reshape: (L⍴R) is extended to allow a non-empty Reshape of an empty in which case the right argument fill element is used, e.g., 2 3⍴⍬.
  • Mismatch: Primitive dyadic not equal underbar (L≢R) equivalent to ~L≡R.
  • Tally: Primitive monadic not equal underbar (≢R) which is equivalent to ⍬⍴(⍴R),1.
  • Indices: Primitive monadic iota underbar (⍸R) which is equivalent to (,R)/,⍳⍴1/R.
  • Array Lookup: Primitive dyadic iota underbar (L⍸R) which for matrices looks up the rows of R in the rows of L. In general, this function looks up the trailing subarrays of R in the vector of trailing subarrays of L, and is equivalent to (⊂⍤¯1 L)⍳⊂⍤(¯1+⍴⍴L) R.
  • Type: Primitive monadic function down tack (⊤R) (Type).
  • Composition: Primitive dyadic operator dieresis circle (L f⍥g R) (Composition).
  • Root: Primitive monadic and dyadic functions (√R and L√R) (Root).
  • Sets: Primitive dyadic functions (L§R, L⊆R, and L⊇R) (Set functions).
  • Primes: Primitive monadic and dyadic functions pi (πR and LπR) (Prime decomposition and Number-theoretic functions).
  • Sequence: Primitive dyadic function (L..R) (Sequence).
  • Variant: Primitive dyadic operator quad colon (f⍠V R and L f⍠V R) (Variant).
  • Anonymous Functions/Operators/Hyperators: one-line grouping of one or more statements all enclosed in braces such as {(+⌿⍵)÷≢⍵}.
  • Determinant: Primitive dyadic operator (f.g R) (Determinant Operator).
  • Convolution: Primitive dyadic operator (L f⍡g R) (Convolution Operator).
  • New System Variables
  • New or Changed System Functions
  • New Datatypes
    • 2-byte Characters (Unicode, that is, UCS-2)
    • 64-bit Integers
    • APAs (Arithmetic Progression Arrays) (e.g., 2 3 4⍴⍳24 and 1E12⍴1)
    • ± Infinity (e.g., for infinity and ¯∞ for negative infinity) — considerable development work needs to be done to this feature to handle the many special cases
    • Rational numbers (e.g., 1r3 and 12345x)
    • Variable precision floating point numbers (e.g., 1.234v and 12v)

Miscellaneous Syntax

  • Strand Assignment: A sequence of names enclosed in parentheses can be assigned to. For example, (A B)←1 2 is the same as A←1 followed by B←2.
  • Modified Assignment: An arbitrary (primitive or user-defined) dyadic function may appear immediately to the left of an assignment arrow. For example, Af←1 is the same as A←A 1, and A[L]f←1 is the same as A[L]←A[L] 1.
  • Modify Strand Assignment: An arbitrary (primitive or user-defined) dyadic function may appear immediately to the left of the assignment arrow used in Strand Assignment (e.g. (A B)f←1 2 is the same as A←Af 1 followed by B←Bf 2).
  • Function/operator/hyperator assignment: A primitive function, operator, or derived function may be assigned to any available name (e.g., F←⍋, or F←¨, or F←∘, or F←+.×).
  • Axis operator with primitive scalar dyadic functions: The axis operator indicates how the coordinates of the lower rank argument map to the coordinates of the higher rank argument. For example, (1 2+[1] 2 3⍴R is equivalent to (⍉3 2⍴1 2)+2 3⍴R.
  • Axis operator with primitive scalar dyadic functions: The order of the values in the axis operator brackets is significant. For example, (2 3⍴L)+[1 2] 2 3 4⍴R and (⍉2 3⍴L)+[2 1] 2 3 4⍴R are identical.
  • Axis operator with the dyadic derived function from the Each operator: As with primitive scalar dyadic functions, the axis operator indicates how the coordinates of the lower rank argument map to the coordinates of the higher rank argument. For example, (2 3⍴L)⍴¨[1 2] 2 3 4⍴R is equivalent to (3 1 2⍉4⌿1 2 3⍴L)⍴¨2 3 4⍴R.
  • Axis operator to Ravel: The order of the values in the axis operator brackets is significant, and may transpose coordinates in the right argument before mapping the values to the result. For example, ,[2 1] R and ,[1 2] R are both valid and have the same shape and values but, in general, the values are in a different order.
  • Axis operator with user-defined functions/operators/hyperators: A user-defined function/operator/hyperator may be sensitive to the axis operator in the same way various primitive functions and operators are. For example, FOO[2 3] R is valid if the function header is defined as ∇ Z←FOO[X] R.
  • Axis operator values may be negative: That is, if the largest allowed value is N, then the allowable range for axis operator values is 1 ¯1[1]-N to N, inclusive.
  • Strand left and right arguments and result to user-defined functions/operators along with optional left argument may be specified: For example, a strand right argument may be specified as ∇ Z←FOO (R1 R2 R3 R4) or, more fully, with a non-displayable result and strands used in all of the result, left, and right arguments with an optional left argument may be specified as ∇ (Z1 Z2)←{L1 L2 L3} (LO OP2[X] RO) (R1 R2 R3 R4).
  • Note that braces are required to surround the left argument of an ambivalent function as in ∇ Z←{L} FOO R.
  • The result of a user-defined function/operator/hyperator may be marked as non-displayable by enclosing it in braces, as in ∇ {Z}←FOO R. If the result part of the header consists of multiple names, either ∇ {Z1 Z2}←FOO R or ∇ ({Z1 Z2})←FOO R or ∇ {(Z1 Z2)}←FOO R may be used to mark the result as non-displayable.
  • Control structures on one line or split across multiple lines (e.g., :for I :in ⍳N ⋄ ... ⋄ :endfor).
  • Point Notation (Base, Euler, Pi, and Gamma) are extensions to the familiar Decimal and Exponential Point Notation for entering numeric constants. For example, the numeric constant 16bffff is a shorthand for calculating 16⊥15 15 15 15.
  • Trains: e.g., avg←(+⌿ ÷ ≢) applies the functions to its argument(s) in a particular way (in this case, to compute the average of a numeric vector).
  • System Labels: ⎕PRO, ⎕ID, and ⎕MS in user-defined functions/operators.

System commands

Session Manager

  • Function editor: this feature may be invoked by typing by itself, or followed by a name, or )EDIT by itself, or )EDIT followed by a name, or by double-right-clicking on a function name in the session manager or function editor windows
  • Multiple workspaces may be open at the same time and switched between via Tabs
  • Workspaces are saved as plain text ASCII files
  • All variable names are two-byte characters (Unicode, that is, UCS-2)
  • Array rank and dimension limit of 64 bits
  • Multilevel Undo in function editing
  • Undo buffer saved with function for reuse on next edit