Language Features: Difference between revisions

From NARS2000
Jump to navigationJump to search
(43 intermediate revisions by 2 users not shown)
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''' &mdash;  <apll>16b10FFFF</apll> as a shorthand for <apll>16{base}1 0 15 15 15 15</apll></li><li>'''Pi''' &mdash;  <apll>2p3</apll> as a shorthand for <apll><sup>3</sup></apll> or <apll>2×(○1)*3</apll></li><li>'''Euler''' &mdash; <apll>2x3</apll> as a shorthand for <apll>2e<sup>3</sup></apll> or <apll>(*1)*3</apll>.</li></ul>
* [[Point Notation]]:   
* [[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 vector).
** '''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>45<pn>v</pn></apll> is a shorthand for <apll>10⊥4 5 31</apll>
* [[System Labels]]:  <apll>⎕PRO</apll> and <apll>⎕ID</apll> in user-defined functions/operators.
** '''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...)
** '''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...)
** '''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...)
** '''Hypercomplex''' &mdash; <apll>2<pn>J</pn>3</apll>, <apll>2<pn>i</pn>3</apll> (both equal to <apll>2+3×√¯1</apll>), <apll>2<pn>ad</pn>3</apll> (Angle in Degrees), <apll>2<pn>ar</pn>3</apll> (Angle in Radians), or <apll>2<pn>au</pn>3</apll> (Angle in Unit Normalized) 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''' &mdash; <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''' &mdash; <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).
* [[Anonymous Functions/Operators]]:  multi-line grouping of one or more statements all enclosed in braces such as <apll>{(+⌿⍵)÷≢⍵}</apll>.


==Primitive functions==
==Primitive functions==
* [[Array Lookup]]:  <apll>L⍸R</apll>
* [[Condense]]:  <apll>&lt;R</apll>
* [[Dilate]]:  <apll>&gt;R</apll>
* [[Find]]:  <apll>L⍷R</apll>
* [[Find]]:  <apll>L⍷R</apll>
* [[Index Generator]]:  <apll>⍳R</apll>
* [[Index Generator]]:  <apll>⍳R</apll>
Line 23: Line 33:
* [[Primes]]: <apll>πR</apll> and <apll>LπR</apll>
* [[Primes]]: <apll>πR</apll> and <apll>LπR</apll>
* [[Reshape]]:  <apll>L⍴R</apll>
* [[Reshape]]:  <apll>L⍴R</apll>
* [[Tally]]:  <apll>&gt;R</apll>
* [[Root]]:  <apll>√R</apll> and <apll>L√R</apll>
* [[Sequence]]:  <apll>L..R</apll>
* [[Sets]]:  <apll>L§R</apll>, <apll>L⊆R</apll>, <apll>L⊇R</apll>
* [[Tally]]:  <apll>≢R</apll>
* [[Without]]:  <apll>L~R</apll>
* [[Without]]:  <apll>L~R</apll>


==Primitive operators==
==Primitive operators==
* [[Axis]]:  <apll><i>f</i>[<i>X</i>]</apll>, <apll><i>f op1</i>[<i>X</i>]</apll>, <apll><i>f op2</i>[<i>X</i>]g</apll>
* [[Axis]]:  <apll><i>f</i>[<i>X</i>]</apll>, <apll><i>f op1</i>[<i>X</i>]</apll>, <apll><i>f op2</i>[<i>X</i>]g</apll>
* [[Combinatorial]]:  <apll><i>a</i>‼R</apll> &nbsp;&nbsp; (monadic derived function)
* [[Commute-Duplicate|Commute]]:  <apll>L <i>f</i>⍨ R ←→ R <i>f</i> L</apll> &nbsp;&nbsp;&nbsp; (dyadic derived function)
* [[Composition]]:  <apll><i>f</i>⍥<i>g</i></apll>
* [[Composition]]:  <apll><i>f</i>⍥<i>g</i></apll>
* [[Compose]]:  <apll><i>f</i>∘<i>g</i></apll>, &nbsp;&nbsp;<apll><i>f</i>∘R</apll>, &nbsp;&nbsp;<apll>L∘<i>g</i></apll>
* [[Compose]]:  <apll><i>f</i>∘<i>g</i></apll>, &nbsp;&nbsp;<apll><i>f</i>∘R</apll>, &nbsp;&nbsp;<apll>L∘<i>g</i></apll>
* [[Convolution]]:  <apll><i>f</i>⍡<i>g</i></apll> &nbsp;&nbsp;&nbsp; (dyadic derived function)
* [[Determinant Operator|Determinant]]:  <apll><i>f</i>.<i>g</i></apll> &nbsp;&nbsp;&nbsp; (monadic derived function)
* [[Commute-Duplicate|Duplicate]]:  <apll><i>f</i>⍨ R ←→ R <i>f</i> R</apll> &nbsp;&nbsp;&nbsp; (monadic derived function)
* [[Multisets]]:  <apll><i>f</i>⍦</apll>
* [[Multisets]]:  <apll><i>f</i>⍦</apll>
* [[Null]]:  <apll><i>f</i>⊙</apll>
* [[Null]]:  <apll><i>f</i>⊙</apll>
* [[Rank]]:  <apll><i>f</i>⍤[<i>X</i>] Y</apll>
* [[Rank]]:  <apll><i>f</i>⍤[<i>X</i>] Y</apll>
* [[Variant]]:  <apll><i>f</i>⍠V</apll>


==Datatypes==
==Datatypes==
Line 39: Line 58:
* [[Unicode|Unicode Characters]]
* [[Unicode|Unicode Characters]]
* [[Array Predicates]]
* [[Array Predicates]]
* [[Rational and VFP Numbers|Rational Numbers]]:  <apll>1<pn>r</pn>3</apll> and <apll>12345<pn>x</pn></apll>
* [[Rational and VFP Numbers|Variable-precision Floating Point (VFP) Numbers]]:  <apll>1.234<pn>v</pn></apll> and <apll>12<pn>v</pn></apll>
* Complex Numbers:  <apll>1<pn>J</pn>2</apll> or <apll>3.4<pn>i</pn>5</apll> or <apll>2<pn>ad</pn>90</apll> or <apll>2<pn>ar</pn>2.1</apll> or <apll>2<pn>au</pn>0.5</apll>
* Quaternion Numbers:  <apll>1<pn>i</pn>2<pn>j</pn>3<pn>k</pn>4</apll>
* Octonion Numbers:  <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>


==System Functions==
==System Commands==
* [[System Function A|<apll>⎕A</apll>]] (Uppercase English Alphabet)
{{:System Commands}}
* [[System Function AT|<apll>⎕AT</apll>]] (Object Attributes)
* [[System Function AV|<apll>⎕AV</apll>]] (Atomic Vector)
* [[System Function CR|<apll>⎕CR</apll>]] (Canonical Representation)
* [[System Function DM|<apll>⎕DM</apll>]] (Diagnostic Message)
* [[System Function DR|<apll>⎕DR</apll>]] (Data Representation)
* [[System Function EA|<apll>⎕EA</apll>]] (Execute Alternate)
* [[System Function EC|<apll>⎕EC</apll>]] (Execute Controlled)
* [[System Function EM|<apll>⎕EM</apll>]] (Event Message)
* [[System Function ERROR|<apll>⎕ERROR</apll>]] (Signal Error)
* [[System Function ES|<apll>⎕ES</apll>]] (Event Simulate)
* [[System Function ET|<apll>⎕ET</apll>]] (Event Type)
* [[System Function FMT|<apll>⎕FMT</apll>]] (Format)
* [[System Function MF|<apll>⎕MF</apll>]] (Monitor Function)
* [[System Function NC|<apll>⎕NC</apll>]] (Name Class)
* [[System Function NL|<apll>⎕NL</apll>]] (Name List)
* [[System Function SYSID|<apll>⎕SYSID</apll>]] (System Identifier)
* [[System Function SYSVER|<apll>⎕SYSVER</apll>]] (System Version)
* [[System Function TC|<apll>⎕TC</apll>/<apll>⎕TC</apll>xxx]] (Terminal Control)
* [[System Function TF|<apll>⎕TF</apll>]] (Transfer Form)
* [[System Function UCS|<apll>⎕UCS</apll>]] (Universal Character Set)
* [[System Function VR|<apll>⎕VR</apll>]] (Visual Representation)
* [[System Function WA|<apll>⎕WA</apll>]] (Workspace Available)


==System Variables==
==System Variables and Functions==
* [[Scalar System Variables]] (<apll>⎕CT</apll>, &nbsp;&nbsp;<apll>⎕IO</apll>, &nbsp;&nbsp;<apll>⎕PP</apll>, &nbsp;&nbsp;<apll>⎕PW</apll>, &nbsp;&nbsp;<apll>⎕RL</apll>)
{{System Variables}}
* [[System Variable ELX|<apll>⎕ELX</apll>]] (Error Trapping)
* [[System Variable FC|<apll>⎕FC</apll>]] (Format Control)
* [[System Variable IC|<apll>⎕IC</apll>]] (Indeterminate Control)

Revision as of 15:26, 28 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:
    • Base16b10FFFF is a shorthand for 16⊥1 0 15 15 15 15 and 10b45v is a shorthand for 10⊥4 5 31
    • Euler2x3 is a shorthand for 2e3 or 2×(*1)*3 where e is Euler's Number (2.718281828459045...)
    • Pi2p3 is a shorthand for 3 or 2×(○1)*3 where π is Archimedes' constant (3.141592653589793...)
    • Gamma2g3 is a shorthand for 3 where γ is Euler-Mascheroni's Constant (0.5772156649015329...)
    • Hypercomplex2J3, 2i3 (both equal to 2+3×√¯1), 2ad3 (Angle in Degrees), 2ar3 (Angle in Radians), or 2au3 (Angle in Unit Normalized) for a Complex number, 1i2j3k4 for a Quaternion number, and 1i2j3k4l5ij6jk7kl8 for an Octonion number.
    • Rational2r3 is a shorthand for 2÷3 as a Multiple-Precision Integer/Rational number.
    • Variable-Precision Floating2.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).
  • Anonymous Functions/Operators: multi-line grouping of one or more statements all enclosed in braces such as {(+⌿⍵)÷≢⍵}.

Primitive functions

Primitive operators

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