Language Features: Difference between revisions
From NARS2000
Jump to navigationJump to search
(→Syntax) |
|||
Line 8: | Line 8: | ||
<!-- * [[Selective Assignment]]: e.g., <apll>(1 1⍉M)←0</apll> --> | <!-- * [[Selective Assignment]]: e.g., <apll>(1 1⍉M)←0</apll> --> | ||
* [[Sink]]: <apll>←R</apll> | * [[Sink]]: <apll>←R</apll> | ||
* [[Point Notation]]: <ul><li>'''Base''' — <apll>16b10FFFF</apll> as a shorthand for <apll>16{base}1 0 15 15 15 15</apll></li><li>'''Pi''' — <apll>2p3</apll> as a shorthand for <apll>2π<sup>3</sup></apll> or <apll>2×(○1)*3</apll></li><li>'''Euler''' — <apll>2x3</apll> as a shorthand for <apll>2e<sup>3</sup></apll> or <apll>2×(*1)*3</apll>.</li></ul> | * [[Point Notation]]: | ||
<ul> | |||
<li>'''Base''' — <apll>16b10FFFF</apll> as a shorthand for <apll>16{base}1 0 15 15 15 15</apll></li> | |||
<li>'''Pi''' — <apll>2p3</apll> as a shorthand for <apll>2π<sup>3</sup></apll> or <apll>2×(○1)*3</apll></li> | |||
<li>'''Euler''' — <apll>2x3</apll> as a shorthand for <apll>2e<sup>3</sup></apll> or <apll>2×(*1)*3</apll>.</li> | |||
<li>'''Gamma''' — <apll>2g3</apll> as a shorthand for <apll>2γ<sup>3</sup></apll> where <apll>γ</apll> is the [https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant Euler-Mascheroni Constant].</li> | |||
</ul> | |||
* [[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 scalar or vector). | * [[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 scalar or vector). | ||
* [[System Labels]]: <apll>⎕ID</apll>, <apll>⎕MS</apll>, and <apll>⎕PRO</apll> in user-defined functions/operators. | * [[System Labels]]: <apll>⎕ID</apll>, <apll>⎕MS</apll>, and <apll>⎕PRO</apll> in user-defined functions/operators. |
Revision as of 09:59, 22 April 2016
At the moment, the following sections describe only those language features that are New or Enhanced relative to the Extended APL Standard, or that deserve special comment.
Syntax
- Strand Assignment: (A1 A2 ... An)←R
- Modify Assignment: Af←R
- Modify Strand Assignment: (A1 A2 ... An)f←R
- Function/Operator Assignment: A←f, A←op1, A←op2
- Sink: ←R
- Point Notation:
- Base — 16b10FFFF as a shorthand for 16⊥1 0 15 15 15 15
- Pi — 2p3 as a shorthand for 2π3 or 2×(○1)*3
- Euler — 2x3 as a shorthand for 2e3 or 2×(*1)*3.
- Gamma — 2g3 as a shorthand for 2γ3 where γ is the Euler-Mascheroni Constant.
- 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 scalar or vector).
- System Labels: ⎕ID, ⎕MS, and ⎕PRO in user-defined functions/operators.
- Anonymous Functions/Operators: one-line grouping of one or more statements all enclosed in braces such as {(+⌿⍵)÷≢⍵}.
Primitive functions
- Array Lookup: L⍸R
- Find: L⍷R
- Index Generator: ⍳R
- Index Of: L⍳R
- Indexing: R[L], R[L]←A, R[L]f←A, L⌷R, L⍉R, L⊃R
- Indices: ⍸R
- Matrix Inverse/Divide: ⌹R, L⌹R
- Mismatch: L≢R
- Partitioned Enclose: L⊂[X] R
- Primes: πR and LπR
- Reshape: L⍴R
- Root: √R and L√R
- Sequence: L..R
- Sets: L§R, L⊆R, L⊇R
- Tally: ≢R
- Without: L~R
Primitive operators
- Axis: f[X], f op1[X], f op2[X]g
- Composition: f⍥g
- Compose: f∘g, f∘R, L∘g
- Convolution: f⍡g (dyadic derived function)
- Determinant: f.g (monadic derived function)
- Multisets: f⍦
- Null: f⊙
- Rank: f⍤[X] Y
- Variant: f⍠V
Datatypes
- Infinity: ∞ and ¯∞
- Arithmetic Progression Arrays: 2 3 4⍴⍳24
- Unicode Characters
- Array Predicates
- Rational Numbers: 1r3 and 12345x
- Variable-precision Floating Point (VFP) Numbers: 1.234v and 12v
System Commands
System Commands provide features to the user of the APL system, separate from actual workspaces, variables or APL operators. These provide such features as accessing files, saving a workspace, and exiting the APL interpreter. The commands are not case sensitive, so )IN and )in do the same thing.
NARS2000 currently has the following system commands:
|
|
System Variables and Functions
System Variables (A value may be assigned to these except for ⎕DM) | |||||||||
---|---|---|---|---|---|---|---|---|---|
⎕ALX | ⎕CT | ⎕DM | ⎕DT | ⎕ELX | ⎕FC | ⎕FEATURE | ⎕FPC | ⎕IC | ⎕IO |
⎕LR | ⎕LX | ⎕PP | ⎕PR | ⎕PW | ⎕RL | ⎕SA | ⎕WSID | ||
Niladic System Functions (a value cannot be assigned to these) | |||||||||
⎕A | ⎕AV | ⎕EM | ⎕ET | ⎕LC | ⎕NNAMES | ⎕NNUMS | ⎕SI | ⎕SYSID | ⎕SYSVER |
⎕T | ⎕TC | ⎕TCBEL | ⎕TCBS | ⎕TCESC | ⎕TCFF | ⎕TCHT | ⎕TCLF | ⎕TCNL | ⎕TCNUL |
⎕TS | ⎕WA | ||||||||
Monadic or dyadic system functions (a value cannot be assigned to these) | |||||||||
⎕AT | ⎕CR | ⎕DC | ⎕DFT | ⎕DL | ⎕DR | ⎕EA | ⎕EC | ⎕ERROR | ⎕ES |
⎕EX | ⎕FMT | ⎕FX | ⎕MF | ⎕NAPPEND | ⎕NC | ⎕NCREATE | ⎕NERASE | ⎕NINFO | ⎕NL |
⎕NLOCK | ⎕NREAD | ⎕NRENAME | ⎕NREPLACE | ⎕NRESIZE | ⎕NSIZE | ⎕NTIE | ⎕NUNTIE | ⎕STOP | ⎕TF |
⎕TRACE | ⎕UCS | ⎕VR | |||||||
Note that quad functions and variables (except for the ⎕A family of functions) are case insensitive |