Language Features: Difference between revisions
From NARS2000
Jump to navigationJump to search
(→Syntax) |
(→Syntax) |
||
Line 9: | Line 9: | ||
* [[Sink]]: <apll>←R</apll> | * [[Sink]]: <apll>←R</apll> | ||
* [[Point Notation]]: | * [[Point Notation]]: | ||
** '''Base''' — <apll> | ** '''Base''' — <apll>16<pn>b</pn>10FFFF</apll> is a shorthand for <apll>16⊥1 0 15 15 15 15</apll> and <apll>10b45v</apll> is a shorthand for <apll>10⊥4 5 31</apll> | ||
** '''Euler''' — <apll> | ** '''Euler''' — <apll>2<pn>x</pn>3</apll> is a shorthand for <apll>2e<sup>3</sup></apll> or <apll>2×(*1)*3</apll> where <apll>e</apll> is [https://en.wikipedia.org/wiki/E_(mathematical_constant) Euler's Number] (2.718281828459045...) | ||
** '''Pi''' — <apll> | ** '''Pi''' — <apll>2<pn>p</pn>3</apll> is a shorthand for <apll>2π<sup>3</sup></apll> or <apll>2×(○1)*3</apll> where <apll>π</apll> is [https://en.wikipedia.org/wiki/Pi Archimedes' constant] (3.141592653589793...) | ||
** '''Gamma''' — <apll> | ** '''Gamma''' — <apll>2<pn>g</pn>3</apll> is a shorthand for <apll>2γ<sup>3</sup></apll> where <apll>γ</apll> is [https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant Euler-Mascheroni's Constant] (0.5772156649015329...) | ||
** '''Hypercomplex''' — <apll>2<pn>J</pn>3</apll> or <apll>2<pn>i</pn>3</apll> for a Complex number, <apll>1<pn>i</pn>2<pn>j</pn>3<pn>k</pn>4</apll> for a Quaternion number, and <apll>1<pn>i</pn>2<pn>j</pn>3<pn>k</pn>4<pn>l</pn>5<pn>ij</pn>6<pn>jk</pn>7<pn>kl</pn>8</apll> for an Octonion number. | |||
** '''Rational''' — <apll>2<pn>r</pn>3</apll> is a shorthand for <apll>2÷3</apll> as a Multiple-Precision Integer/Rational number. | |||
** '''Variable-Precision Floating''' — <apll>2.3<pn>v</pn></apll> is a shorthand for <apll>2.3</apll> as a Multiple-Precision Floating Point number. | |||
* [[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 13:00, 13 April 2017
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 is a shorthand for 16⊥1 0 15 15 15 15 and 10b45v is a shorthand for 10⊥4 5 31
- Euler — 2x3 is a shorthand for 2e3 or 2×(*1)*3 where e is Euler's Number (2.718281828459045...)
- Pi — 2p3 is a shorthand for 2π3 or 2×(○1)*3 where π is Archimedes' constant (3.141592653589793...)
- Gamma — 2g3 is a shorthand for 2γ3 where γ is Euler-Mascheroni's Constant (0.5772156649015329...)
- Hypercomplex — 2J3 or 2i3 for a Complex number, 1i2j3k4 for a Quaternion number, and 1i2j3k4l5ij6jk7kl8 for an Octonion number.
- Rational — 2r3 is a shorthand for 2÷3 as a Multiple-Precision Integer/Rational number.
- Variable-Precision Floating — 2.3v is a shorthand for 2.3 as a Multiple-Precision Floating Point number.
- 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: multi-line grouping of one or more statements all enclosed in braces such as {(+⌿⍵)÷≢⍵}.
Primitive functions
- Array Lookup: L⍸R
- Condense: <R
- Dilate: >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
- Commute: L f⍨ R ←→ R f L (dyadic derived function)
- Composition: f⍥g
- Compose: f∘g, f∘R, L∘g
- Convolution: f⍡g (dyadic derived function)
- Determinant: f.g (monadic derived function)
- Duplicate: f⍨ R ←→ R f R (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
- Complex Numbers: 1J2 or 3.4i5 or 2ad90 or 2ar2.1 or 2au0.5
- Quaternion Numbers: 1i2j3k4
- Octonion Numbers: 1i2j3k4l5ij6jk7kl8
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 |