# Consistent Extensions in NARS2000

From NARS2000

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 (
*f*∘*g*) (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
- ⎕DT (Distribution Type)
- ⎕FC (Format Control)
- ⎕FPC (Floating Point Control)
- ⎕IC (Indeterminate Control)

- New or Changed System Functions
- ⎕A (Uppercase English Alphabet) — returns the 26-character uppercase English alphabet.
- ⎕AT (Object Attributes) — returns various attributes (Valence, Fix Time, Execution Properties, and Size) of an object
- ⎕AV (Atomic Vector) — has all UCS-2 Unicode characters (65,536 in length)
- L ⎕CR R (Canonical Representation) — L=1 (nested vector of character vectors) and L=2 (character matrix)
- ⎕DM (Diagnostic Message)
- ⎕DR R and L ⎕DR R (Data Representation)
- L ⎕EA R (Execute Alternate)
- ⎕EC R (Execute Controlled)
- ⎕EM (Event Message)
- ⎕ERROR R (Signal Error)
- ⎕ES R and L ⎕ES R (Event Simulate)
- ⎕ET (Event Type)
- ⎕FMT R (Format arrays within Boxes)
- L ⎕FMT R (Format arrays using Format Phrases)
- ⎕MF R (Monitor Function)
- ⎕Nxxxx (Native File Functions)
- ⎕NC R (Name Class) — returns 21 through 24 for System labels, (Unused), Magic functions, and Magic operators.
- ⎕NL R (Name List) — R=21 through 24 lists System labels, (Unused), Magic functions, and Magic operators.
- ⎕STOP (Query/Set STOP Property On Functions)
- ⎕SYSID (System Identification)
- ⎕SYSVER (System Version)
- ⎕TC and other related ⎕TC
*xxx*(Terminal Control) - 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
- ⎕TRACE (Query/Set TRACE Property On Functions)
- ⎕UCS R (Unicode Character Set)
- ⎕VR R (Visual Representation)
- ⎕WA (Workspace Available)

- 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, A
*f*←1 is the same as A←A*f¨*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←A*f*1 followed by B←B*f*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 (R
_{1}R_{2}R_{3}R_{4}) 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 ∇ (Z_{1}Z_{2})←{L_{1}L_{2}L_{3}} (LO OP2[X] RO) (R_{1}R_{2}R_{3}R_{4}). - 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 ∇ {Z
_{1}Z_{2}}←FOO R or ∇ ({Z_{1}Z_{2}})←FOO R or ∇ {(Z_{1}Z_{2})}←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