Language Features: Difference between revisions
(→Syntax) |
No edit summary |
||
Line 2: | Line 2: | ||
==Syntax== | ==Syntax== | ||
* [[Strand Assignment]]: | * [[Strand Assignment]]: (A1 A2 ... An)←R | ||
* [[Modify Assignment]]: | * [[Modify Assignment]]: Af←R | ||
* [[Modify Strand Assignment]]: | * [[Modify Strand Assignment]]: (A1 A2 ... An)f←R | ||
* [[Function/Operator/Hyperator Assignment]]: | * [[Function/Operator/Hyperator Assignment]]: A←f, A←op1, A←op2 | ||
* [[Binding Strength]]: How Variables, Functions, Operators, and Hyperators combine | |||
* [[Sink]]: | * [[Sink]]: ←R | ||
* [[Point Notation]]: | * [[Point Notation]]: | ||
** '''Base''' | ** '''Base''' — 1610FFFF is a shorthand for 16⊥1 0 15 15 15 15 and 1045v is a shorthand for 10⊥4 5 31 | ||
** '''Euler''' | ** '''Euler''' — 23 is a shorthand for 2e3 or 2×(*1)*3 where e is [https://en.wikipedia.org/wiki/E_(mathematical_constant) Euler's Number] (2.718281828459045...) | ||
** '''Pi''' | ** '''Pi''' — 23 is a shorthand for 2π3 or 2×(○1)*3 where π is [https://en.wikipedia.org/wiki/Pi Archimedes' constant] (3.141592653589793...) | ||
** '''Gamma''' | ** '''Gamma''' — 23 is a shorthand for 2γ3 where γ is [https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant Euler-Mascheroni's Constant] (0.5772156649015329...) | ||
** '''Hypercomplex''' | ** '''Hypercomplex''' — 23, 23 (both equal to 2+3×√¯1), 23 (Angle in Degrees), 23 (Angle in Radians), or 23 (Angle in Unit Normalized) for a Complex number, 1234 for a Quaternion number, and 12345678 for an Octonion number. | ||
** '''Rational''' | ** '''Rational''' — 23 is a shorthand for 2÷3 as a Multiple-Precision Integer/Rational number. | ||
** '''Variable-Precision Floating''' | ** '''Variable-Precision Floating''' — 2.3 is a shorthand for 2.3 as a Multiple-Precision Floating Point number. | ||
** '''Ball Arithmetic''' | ** '''Ball Arithmetic''' — 2.31¯17 is a shorthand for a Ball whose Midpoint and Radius are 2.3 and 1¯17, respectively. | ||
* [[Trains]]: e.g., | * [[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). | ||
* [[Anonymous Functions/Operators/Hyperators]]: multi-line grouping of one or more statements all enclosed in braces such as | * [[Anonymous Functions/Operators/Hyperators]]: multi-line grouping of one or more statements all enclosed in braces such as {(+⌿⍵)÷≢⍵}. | ||
==Primitive functions== | ==Primitive functions== | ||
{| border="0" cellpadding="0" cellspacing="0" | {| border="0" cellpadding="0" cellspacing="0" | ||
| | |'''Name'''|| '''Symbol/Syntax'''||'''Function Valence''' | ||
|- | |- | ||
|[[Array Lookup]]|| | |[[Array Lookup]]|| L⍸R ||dyadic | ||
|- | |- | ||
|[[Condense]]|| | |[[Condense]]|| <[X] R ||monadic | ||
|- | |- | ||
|[[Dilate]]|| | |[[Dilate]]|| >[X] R ||monadic | ||
|- | |- | ||
|[[Expand]]|| | |[[Expand]]|| L\[X] R ||dyadic | ||
|- | |- | ||
|[[Find]]|| | |[[Find]]|| L⍷R ||dyadic | ||
|- | |- | ||
|[[Index Generator]]|| | |[[Index Generator]]|| ⍳R ||monadic | ||
|- | |- | ||
|[[Index Of]]|| | |[[Index Of]]|| L⍳R ||dyadic | ||
|- | |- | ||
|[[Indexing]]|| | |[[Indexing]]|| R[L], R[L]←A, R[L]f←A, L⌷[X] R, L⍉R, L⊃R ||dyadic | ||
|- | |- | ||
|[[Indices]]|| | |[[Indices]]|| ⍸R ||monadic | ||
|- | |- | ||
|[[Matrix Inverse/Divide]]|| | |[[Matrix Inverse/Divide]]|| ⌹R, L⌹R ||ambivalent | ||
|- | |- | ||
|[[Mismatch]]|| | |[[Mismatch]]|| L≢R ||dyadic | ||
|- | |- | ||
|[[Partitioned Enclose]]|| | |[[Partitioned Enclose]]|| L⊂[X] R ||dyadic | ||
|- | |- | ||
|[[Primes]]|| | |[[Primes]]|| πR, LπR ||ambivalent | ||
|- | |- | ||
|[[Reshape]]|| | |[[Reshape]]|| L⍴R ||dyadic | ||
|- | |- | ||
|[[Root]]|| | |[[Root]]|| √R, L√[X] R ||ambivalent | ||
|- | |- | ||
|[[Sequence]]|| | |[[Sequence]]|| L..R ||dyadic | ||
|- | |- | ||
|[[Sets]]|| | |[[Sets]]|| L§R, L⊆R, L⊇R ||dyadic | ||
|- | |- | ||
|[[Tally]]|| | |[[Tally]]|| ≢R ||monadic | ||
|- | |- | ||
|[[Without]]|| | |[[Without]]|| L~R ||dyadic | ||
|} | |} | ||
where | where L is the Left argument, R is the Right argument, and [X] is an optional Axis value. | ||
==Primitive operators== | ==Primitive operators== | ||
{| border="0" cellpadding="0" cellspacing="0" | {| border="0" cellpadding="0" cellspacing="0" | ||
| | |'''Name'''|| '''Symbol/Syntax'''||'''Derived Function Valence''' | ||
|- | |- | ||
|[[Axis]]|| | |[[Axis]]|| {L} f[X] R, {L} (f op1[X]) R, {L} (f op2[X] g) R ||ambivalent | ||
|- | |- | ||
|[[Combinatorial]]|| | |[[Combinatorial]]|| a‼ R ||monadic | ||
|- | |- | ||
|[[Commute-Duplicate|Commute]]|| | |[[Commute-Duplicate|Commute]]|| L f⍨ R ←→ R f L ||dyadic | ||
|- | |- | ||
|[[Composition]]|| | |[[Composition]]|| {L} f⍥g R ||ambivalent | ||
|- | |- | ||
|[[Compose]]|| | |[[Compose]]|| {L} f∘g R, (f∘b) R, a∘g R ||ambivalent/monadic | ||
|- | |- | ||
|[[Convolution]]|| | |[[Convolution]]|| L f⍡g R ||dyadic | ||
|- | |- | ||
|[[Determinant Operator|Determinant]]|| | |[[Determinant Operator|Determinant]]|| f.g R ||monadic | ||
|- | |- | ||
|[[Commute-Duplicate|Duplicate]]|| | |[[Commute-Duplicate|Duplicate]]|| f⍨ R ←→ R f R ||monadic | ||
|- | |- | ||
|[[Matrix]]|| | |[[Matrix]]|| {L} f⌻ R, ∘⌻ R ||ambivalent/monadic | ||
|- | |- | ||
|[[Multisets]]|| | |[[Multisets]]|| {L} f⍦ R ||ambivalent | ||
|- | |- | ||
|[[Null]]|| | |[[Null]]|| {L} f⊙ R ||ambivalent | ||
|- | |- | ||
|[[Power]]|| | |[[Power]]|| {L} f⍣g R, {L} (f⍣b) R ||ambivalent | ||
|- | |- | ||
|[[Rank]]|| | |[[Rank]]|| {L} (f⍤[X] b) R ||ambivalent | ||
|- | |- | ||
|[[Variant]]|| | |[[Variant]]|| {L} (f⍠b) R ||ambivalent | ||
|} | |} | ||
where | where {L} is an optional Left argument, R is the Right argument, f and g represent Functions, a and b represent Variables, and [X] is an optional Axis value. | ||
==Datatypes== | ==Datatypes== | ||
* [[Infinity]]: | * [[Infinity]]: ∞ and ¯∞ | ||
* [[APA|Arithmetic Progression Arrays]]: | * [[APA|Arithmetic Progression Arrays]]: 2 3 4⍴⍳24 | ||
* [[Unicode|Unicode Characters]] | * [[Unicode|Unicode Characters]] | ||
* [[Array Predicates]] | * [[Array Predicates]] | ||
* [[Rational and VFP Numbers|Rational Numbers]]: | * [[Rational and VFP Numbers|Rational Numbers]]: 13 and 12345 | ||
* [[Rational and VFP Numbers|Variable-precision Floating Point (VFP) Numbers]]: | * [[Rational and VFP Numbers|Variable-precision Floating Point (VFP) Numbers]]: 1.234 and 12 | ||
* [[Hypercomplex Numbers|Complex Numbers]]: | * [[Hypercomplex Numbers|Complex Numbers]]: 12 or 3.45 or 290 or 22.1 or 20.5 | ||
* [[Hypercomplex Numbers|Quaternion Numbers]]: | * [[Hypercomplex Numbers|Quaternion Numbers]]: 1234 | ||
* [[Hypercomplex Numbers|Octonion Numbers]]: | * [[Hypercomplex Numbers|Octonion Numbers]]: 12345678 | ||
* [[Ball Arithmetic]]: | * [[Ball Arithmetic]]: 2.3 is a shorthand for a Ball whose Midpoint and Radius are 2.3 and 2*¯53, respectively, because the Midpoint (2.3) cannot be represented exactly in double-precision floating point format with the standard 53 bits of precision. | ||
==System Commands== | ==System Commands== |
Revision as of 16:29, 19 March 2019
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/Hyperator Assignment: A←f, A←op1, A←op2
- Binding Strength: How Variables, Functions, Operators, and Hyperators combine
- Sink: ←R
- Point Notation:
- Base — 1610FFFF is a shorthand for 16⊥1 0 15 15 15 15 and 1045v is a shorthand for 10⊥4 5 31
- Euler — 23 is a shorthand for 2e3 or 2×(*1)*3 where e is Euler's Number (2.718281828459045...)
- Pi — 23 is a shorthand for 2π3 or 2×(○1)*3 where π is Archimedes' constant (3.141592653589793...)
- Gamma — 23 is a shorthand for 2γ3 where γ is Euler-Mascheroni's Constant (0.5772156649015329...)
- Hypercomplex — 23, 23 (both equal to 2+3×√¯1), 23 (Angle in Degrees), 23 (Angle in Radians), or 23 (Angle in Unit Normalized) for a Complex number, 1234 for a Quaternion number, and 12345678 for an Octonion number.
- Rational — 23 is a shorthand for 2÷3 as a Multiple-Precision Integer/Rational number.
- Variable-Precision Floating — 2.3 is a shorthand for 2.3 as a Multiple-Precision Floating Point number.
- Ball Arithmetic — 2.31¯17 is a shorthand for a Ball whose Midpoint and Radius are 2.3 and 1¯17, respectively.
- 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).
- Anonymous Functions/Operators/Hyperators: multi-line grouping of one or more statements all enclosed in braces such as {(+⌿⍵)÷≢⍵}.
Primitive functions
Name | Symbol/Syntax | Function Valence |
Array Lookup | L⍸R | dyadic |
Condense | <[X] R | monadic |
Dilate | >[X] R | monadic |
Expand | L\[X] R | dyadic |
Find | L⍷R | dyadic |
Index Generator | ⍳R | monadic |
Index Of | L⍳R | dyadic |
Indexing | R[L], R[L]←A, R[L]f←A, L⌷[X] R, L⍉R, L⊃R | dyadic |
Indices | ⍸R | monadic |
Matrix Inverse/Divide | ⌹R, L⌹R | ambivalent |
Mismatch | L≢R | dyadic |
Partitioned Enclose | L⊂[X] R | dyadic |
Primes | πR, LπR | ambivalent |
Reshape | L⍴R | dyadic |
Root | √R, L√[X] R | ambivalent |
Sequence | L..R | dyadic |
Sets | L§R, L⊆R, L⊇R | dyadic |
Tally | ≢R | monadic |
Without | L~R | dyadic |
where L is the Left argument, R is the Right argument, and [X] is an optional Axis value.
Primitive operators
Name | Symbol/Syntax | Derived Function Valence |
Axis | {L} f[X] R, {L} (f op1[X]) R, {L} (f op2[X] g) R | ambivalent |
Combinatorial | a‼ R | monadic |
Commute | L f⍨ R ←→ R f L | dyadic |
Composition | {L} f⍥g R | ambivalent |
Compose | {L} f∘g R, (f∘b) R, a∘g R | ambivalent/monadic |
Convolution | L f⍡g R | dyadic |
Determinant | f.g R | monadic |
Duplicate | f⍨ R ←→ R f R | monadic |
Matrix | {L} f⌻ R, ∘⌻ R | ambivalent/monadic |
Multisets | {L} f⍦ R | ambivalent |
Null | {L} f⊙ R | ambivalent |
Power | {L} f⍣g R, {L} (f⍣b) R | ambivalent |
Rank | {L} (f⍤[X] b) R | ambivalent |
Variant | {L} (f⍠b) R | ambivalent |
where {L} is an optional Left argument, R is the Right argument, f and g represent Functions, a and b represent Variables, and [X] is an optional Axis value.
Datatypes
- Infinity: ∞ and ¯∞
- Arithmetic Progression Arrays: 2 3 4⍴⍳24
- Unicode Characters
- Array Predicates
- Rational Numbers: 13 and 12345
- Variable-precision Floating Point (VFP) Numbers: 1.234 and 12
- Complex Numbers: 12 or 3.45 or 290 or 22.1 or 20.5
- Quaternion Numbers: 1234
- Octonion Numbers: 12345678
- Ball Arithmetic: 2.3 is a shorthand for a Ball whose Midpoint and Radius are 2.3 and 2*¯53, respectively, because the Midpoint (2.3) cannot be represented exactly in double-precision floating point format with the standard 53 bits of precision.
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 |