Consistent Extensions in NARS2000

From NARS2000
Revision as of 05:20, 23 March 2008 by Sudleyplace (talk | contribs)
Jump to navigationJump to search

The following features are considered consistent extensions to the Extended APL Standard in that they replace error-producing behavior with non-error-producing behavior:

  • Language Features
    • Sink: monadic , e.g. ←A to suppress the display of A.
    • Unified index reference, assignment, and modify assignment (R[L], R[L]←A, and R[L]fn←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]fn←A.
    • Dyadic operator jot () (composition) is used to join two functions or a function and a variable to produce a derived function (e.g., f←,∘⍋∘⍋∘,) which is applied as a single function. For example, the function f←*∘2 when applied monadically, squares its argument.
    • Monadic operator null (): 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 () 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 () extended to rank > 1 left arguments returns an array of vector indices to the left argument (via an internal magic function).
    • ± 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.
    • Monadic and dyadic domino () — matrix inverse/divide extended to use Moore-Penrose pseudo-inverse algorithm via Singular Value Decomposition.
    • Prototypes for all primitive functions and operators.
  • Miscellaneous Syntax
    • Strand Assignment: A sequence of names enclosed in parentheses can be assigned to, e.g. (A B)←1 2 is the same as A←1 and B←2.
    • Modify Assignment: An arbitrary (primitive or user-defined) dyadic function may appear immediately to the left of an assignment arrow, e.g. A fn←1 is the same as A←A fn 1, and A[L]fn←1 is the same as A[L]←A[L] fn 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)fn←1 2 is the same as A←A fn 1 and B←B fn 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←∘).
    • 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 (3 2⍴L)+[2 1] 2 3 4⍴R are both valid but, in general, have different values.
    • 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 as are various primitive functions and operators. For example, foo[2 3] R is valid if the function header is defined as ∇ Z←foo[X] R.
    • Strand left and right arguments and result to user-defined functions/operators along with optional left argument (e.g., ∇ Z←FOO (R1 R2 R3 R4) or, more fully, ∇ (Z1 Z2)←[L1 L2 L3] (LO OP2[X] RO) (R1 R2 R3 R4).
    • Note that brackets are required to surround the left argument of an ambivalent function as in ∇ Z←[L] FOO R — Is this an inconsistent extension?
    • 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.
  • 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.