Language Features: Difference between revisions

From NARS2000
Jump to navigationJump to search
Line 9: Line 9:
* [[Sink]]:  <apll>←R</apll>
* [[Sink]]:  <apll>←R</apll>
* [[Point Notation]]:   
* [[Point Notation]]:   
** '''Base''' &mdash;  <apll>16<pn>b</pn>10FFFF</apll> is a shorthand for <apll>16⊥1 0 15 15 15 15</apll> and <apll>10<pn>b</pn>45v</apll> is a shorthand for <apll>10⊥4 5 31</apll>
** '''Base''' &mdash;  <apll>16<bn/>10FFFF</apll> is a shorthand for <apll>16⊥1 0 15 15 15 15</apll> and <apll>10<bn/>45v</apll> is a shorthand for <apll>10⊥4 5 31</apll>
** '''Euler''' &mdash; <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...)
** '''Euler''' &mdash; <apll>2<x/>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''' &mdash;  <apll>2<pn>p</pn>3</apll> is a shorthand for <apll>2&pi;<sup>3</sup></apll> or <apll>2×(○1)*3</apll> where <apll>&pi;</apll> is [https://en.wikipedia.org/wiki/Pi Archimedes' constant] (3.141592653589793...)
** '''Pi''' &mdash;  <apll>2<pn/>3</apll> is a shorthand for <apll>2&pi;<sup>3</sup></apll> or <apll>2×(○1)*3</apll> where <apll>&pi;</apll> is [https://en.wikipedia.org/wiki/Pi Archimedes' constant] (3.141592653589793...)
** '''Gamma''' &mdash; <apll>2<pn>g</pn>3</apll> is a shorthand for <apll>2&gamma;<sup>3</sup></apll> where <apll>&gamma;</apll> is [https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant Euler-Mascheroni's Constant] (0.5772156649015329...)
** '''Gamma''' &mdash; <apll>2<g/>3</apll> is a shorthand for <apll>2&gamma;<sup>3</sup></apll> where <apll>&gamma;</apll> is [https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant Euler-Mascheroni's Constant] (0.5772156649015329...)
** '''Hypercomplex''' &mdash; <apll>2<hc>J</hc>3</apll>, <apll>2<hc>i</hc>3</apll> (both equal to <apll>2+3×√¯1</apll>), <apll>2<hc>ad</hc>3</apll> (Angle in Degrees), <apll>2<hc>ar</hc>3</apll> (Angle in Radians), or <apll>2<hc>au</hc>3</apll> (Angle in Unit Normalized) for a Complex number, <apll>1<hc>i</hc>2<hc>j</hc>3<hc>k</hc>4</apll> for a Quaternion number, and <apll>1<hc>i</hc>2<hc>j</hc>3<hc>k</hc>4<hc>l</hc>5<hc>ij</hc>6<hc>jk</hc>7<hc>kl</hc>8</apll> for an Octonion number.
** '''Hypercomplex''' &mdash; <apll>2<J/>3</apll>, <apll>2<in/>3</apll> (both equal to <apll>2+3×√¯1</apll>), <apll>2<ad/>3</apll> (Angle in Degrees), <apll>2<ar/>3</apll> (Angle in Radians), or <apll>2<au/>3</apll> (Angle in Unit Normalized) for a Complex number, <apll>1<in/>2<j/>3<k/>4</apll> for a Quaternion number, and <apll>1<in/>2<j/>3<k/>4<l/>5<ij/>6<jk/>7<kl/>8</apll> for an Octonion number.
** '''Rational''' &mdash; <apll>2<pn>r</pn>3</apll> is a shorthand for <apll>2÷3</apll> as a Multiple-Precision Integer/Rational number.
** '''Rational''' &mdash; <apll>2<r/>3</apll> is a shorthand for <apll>2÷3</apll> as a Multiple-Precision Integer/Rational number.
** '''Variable-Precision Floating''' &mdash; <apll>2.3<pn>v</pn></apll> is a shorthand for <apll>2.3</apll> as a Multiple-Precision Floating Point number.
** '''Variable-Precision Floating''' &mdash; <apll>2.3<v/></apll> is a shorthand for <apll>2.3</apll> as a Multiple-Precision Floating Point number.
** '''Ball Arithmetic''' &mdash; <apll>2.3<pn>{pom}</pn>1<pn>E</pn>{overbar}17</apll> is a shorthand for a Ball whose Midpoint and Radius are <apll>2.3</apll> and <apll>1<pn>E</pn>{overbar}17</apll>, respectively.
** '''Ball Arithmetic''' &mdash; <apll>2.3<pom/>1<E/>¯17</apll> is a shorthand for a Ball whose Midpoint and Radius are <apll>2.3</apll> and <apll>1<E/>¯17</apll>, respectively.
* [[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).
* [[Anonymous Functions/Operators]]:  multi-line grouping of one or more statements all enclosed in braces such as <apll>{(+⌿⍵)÷≢⍵}</apll>.
* [[Anonymous Functions/Operators]]:  multi-line grouping of one or more statements all enclosed in braces such as <apll>{(+⌿⍵)÷≢⍵}</apll>.

Revision as of 23:15, 4 August 2018

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:
    • Base1610FFFF is a shorthand for 16⊥1 0 15 15 15 15 and 1045v is a shorthand for 10⊥4 5 31
    • Euler23 is a shorthand for 2e3 or 2×(*1)*3 where e is Euler's Number (2.718281828459045...)
    • Pi23 is a shorthand for 3 or 2×(○1)*3 where π is Archimedes' constant (3.141592653589793...)
    • Gamma23 is a shorthand for 3 where γ is Euler-Mascheroni's Constant (0.5772156649015329...)
    • Hypercomplex23, 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.
    • Rational23 is a shorthand for 2÷3 as a Multiple-Precision Integer/Rational number.
    • Variable-Precision Floating2.3 is a shorthand for 2.3 as a Multiple-Precision Floating Point number.
    • Ball Arithmetic2.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: 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} fg R     ambivalent
Compose     {L} fg R,    (fb) R,    ag R     ambivalent/monadic
Convolution     L fg 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} fg R,    {L} (fb) R     ambivalent
Rank     {L} (f⍤[X] b) R     ambivalent
Variant     {L} (fb) 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

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:

)BOX Turn ON/OFF box around output
)CLEAR Start a new session manager window with an empty workspace
)CLOSE
)COPY
)DROP
)EDIT Create a new function in the workspace or edit an existing function
)ERASE Delete a variable or function in the current workspace
)EXIT Close down the interpreter and exit the program. Same as )OFF
)FNS
)FOP Display functions, operators, and hyperators. Same as )FOPS
)FOPS
)HYP Display hyperators only
)IN
)INASCII    
)LIB
)LAOD Alternative spelling of )LOAD
)LOAD Load an existing workspace
)NEWTAB
)NMS
)OFF Close down the interpreter and exit the program. Same as )EXIT
)OPEN
)OPS Display operators only
)OUT
)RESET
)SAVE Save the current workspace
)SVAE Alternative spelling for )SAVE
)SI workspace State Indicator
)SIC State Indicator Clear
)SINL
)SYMB
)ULIB
)VARS
)XLOAD
)WSID
 

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