Consistent Extensions in NARS2000: Difference between revisions
From NARS2000
Jump to navigationJump to search
Sudleyplace (talk | contribs) |
Sudleyplace (talk | contribs) |
||
Line 41: | Line 41: | ||
== 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>. | * [[Modify_Assignment|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>. | ||
* 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_Assignment|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>). | ||
* 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]]: 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 operator values may be negative | * [[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|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> — Is this an '''inconsistent''' extension? | ||
* 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|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 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. | * [[User-Defined_Functions/Operators|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 on one line or split across multiple lines (e.g., <apll>:for I :in ⍳N ⋄ ... ⋄ :endfor</apll>). | * [[Control_Structures|Control structures]] on one line or split across multiple lines (e.g., <apll>:for I :in ⍳N ⋄ ... ⋄ :endfor</apll>). | ||
* Point Notation (<b>Base</b>, <b>Euler</b>, and <b>Pi</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 entering <apll>16⊥15 15 15 15</apll>. | * [[Point_Notation|Point Notation]] (<b>Base</b>, <b>Euler</b>, and <b>Pi</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 entering <apll>16⊥15 15 15 15</apll>. | ||
== System commands == | == System commands == |
Revision as of 14:33, 24 November 2008
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] — 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 (f∘g) (composition) 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.
- 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 (via an internal magic function).
- Dyadic iota (L⍳R) extended to rank > 1 left arguments returns an array of vector indices to the left argument (via an internal magic function).
- Index reference, assignment, modify assignment, squad, and pick (R[L], R[L]←A, R[L]f←A, L⌷R, and L⊃R) 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.
- 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.
- Out of range numeric assignments to ⎕PP and ⎕PW are set to the value in the allowable range nearest the ceiling of the given number. For example, if ⎕PP is set to 23.7, that value is rounded down to 17, the largest value that system variable may assume.
- Assigning a simple empty vector to a scalar system variable (⎕CT, ⎕IO, ⎕PP, ⎕PW, or ⎕RL) assigns the system default value to the variable.
- New System Variables
- ⎕FC (Format Control)
- ⎕IC (Indeterminate Control)
- New or Changed System Functions
- ⎕AV (Atomic Vector) — has all UCS-2 Unicode characters (65,536 in length)
- L ⎕CR R (Canonical Representation) — 1=|L (nested vector of character vectors) and 2=|L (character matrix); L<0 returns representations of internal magic functions
- ⎕DM (Diagnostic Message)
- ⎕DR R and L ⎕DR R (Data Representation)
- ⎕ERROR R (Signal Error)
- ⎕MF R (Monitor Function)
- ⎕NL R (Name List) — R=8 lists Magic Functions.
- ⎕SIZE R (Object Size)
- ⎕SYSID (System Identification)
- ⎕SYSVER (System Version)
- ⎕TC and other related ⎕TCxxx (Terminal Character)
- L ⎕TF R (Transfer Form) — 1=|L (Type 1 Transfer Form) and 2=|L (Type 2 Transfer Form); L<0 interprets R and the result as Unicode characters; L>0 interprets them as APL2 characters
- ⎕TYPE R (Object Prototype)
- ⎕UCS R (Unicode Character Set)
- New Datatypes
- 2-byte Characters (Unicode, that is, UCS-2)
- 64-bit Integers
- APAs (Arithmetic Progression Arrays) (e.g., 2 3 4⍴⍳24)
- ± 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
Miscellaneous Syntax
- [[Strand_Assignment}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.
- Modify 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←Af 1, and A[L]f←1 is the same as A[L]←A[L]f 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 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: A user-defined function/operator 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 — Is this an inconsistent extension?
- The result of a user-defined function/operator 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.
- User-defined function/operator prototype line label (⎕PROTOTYPE:): When the user-defined function/operator is called to produce a prototype, this entry point is where execution of the function starts.
- Control structures on one line or split across multiple lines (e.g., :for I :in ⍳N ⋄ ... ⋄ :endfor).
- Point Notation (Base, Euler, and Pi) are extensions to the familiar Decimal and Exponential Point Notation for entering numeric constants. For example, the numeric constant 16bffff is a shorthand for entering 16⊥15 15 15 15.
System commands
- )CLOSE
- )EDIT
- )EXIT
- )NEWTAB
- )RESET
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