APL syntax: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>RikedyP
m (7 revisions imported: Migrate from miraheze)
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
APL's core syntactic principles are:
APL's core syntactic principles are:
* [[Array model|Arrays]] as first class citizens
* [[Array model|Arrays]] as first class citizens
* Functions take arrays as input and produce arrays as output
* Functions take arrays as argument(s) and produce arrays as result
* Operators take functions as operands and produce derived functions
* Functions have long right scope
* Operators take functions and/or arrays as operand(s) and produce derived functions
* Operators have long left scope


== Example array definitions ==
== Example array definitions ==
<pre class="language-apl">
<source lang=apl>
       simplenumvec←1 2 3 4 ⍝ A simple numeric vector
       simplenumvec←1 2 3 4 ⍝ A simple numeric vector
       simplecharvec←'ABCD' ⍝ A simple character vector
       simplecharvec←'ABCD' ⍝ A simple character vector
</pre>
</source>


== Example function definition ==
== Example function definition ==
<pre class="language-apl">
<source lang=apl>
     ∇  r←l Tradfn r               
     ∇  r←l Tradfn r               
[1]    ⍝ An infix (dyadic) tradfn
[1]    ⍝ An infix (dyadic) tradfn
[2]    r←l r                     
[2]    r←l r                     
     ∇   
     ∇   
</pre>
</source>
{{Works in|[[Dyalog APL]], [[APL2]], [[GNU APL]], [[NARS2000]]}}
{{Works in|[[Dyalog APL]], [[APL2]], [[GNU APL]], [[NARS2000]]}}


== Example operator definition ==
== Example operator definition ==
<pre class="language-apl">
<source lang=apl>
     ∇ r←larg(Main OVER PreProc)rarg                                                 
     ∇ r←larg(Main OVER PreProc)rarg                                                 
[1]    r←(PreProc larg)Main(PreProc rarg)                                             
[1]    r←(PreProc larg)Main(PreProc rarg)                                             
     ∇   
     ∇   
</pre>
</source>
== Example function application ==
== Example function application ==
<pre class="language-apl">
<source lang=apl>
</pre>
      ÷3        ⍝ Prefix primitive function
0.3333333333
      1+2        ⍝ Infix primitive function
3
      +/1 2 3 4  ⍝ Prefix primitive derived function
10
      2+/1 2 3 4 ⍝ Infix primitive derived function
3 5 7
</source>
 
== Scoping rules ==
 
=== Functions ===
 
=== Operators ===
 
{{APL dialects}}

Revision as of 14:49, 20 November 2019

APL's core syntactic principles are:

  • Arrays as first class citizens
  • Functions take arrays as argument(s) and produce arrays as result
  • Functions have long right scope
  • Operators take functions and/or arrays as operand(s) and produce derived functions
  • Operators have long left scope

Example array definitions

      simplenumvec←1 2 3 4 ⍝ A simple numeric vector
      simplecharvec←'ABCD' ⍝ A simple character vector

Example function definition

    ∇  r←l Tradfn r              
[1]    ⍝ An infix (dyadic) tradfn
[2]    r←l r                     
    ∇

Example operator definition

     ∇ r←larg(Main OVER PreProc)rarg                                                 
[1]    r←(PreProc larg)Main(PreProc rarg)                                            
     ∇

Example function application

      ÷3         ⍝ Prefix primitive function
0.3333333333
      1+2        ⍝ Infix primitive function
3
      +/1 2 3 4  ⍝ Prefix primitive derived function
10
      2+/1 2 3 4 ⍝ Infix primitive derived function
3 5 7

Scoping rules

Functions

Operators

APL dialects [edit]
Maintained APL+WinAPL2APL64APL\ivApletteAprilCo-dfnsDyalog APLDyalog APL Visiondzaima/APLGNU APLKapNARS2000Pometo
Historical A Programming LanguageA+ (A) ∙ APL#APL2CAPL\360APL/700APL\1130APL\3000APL.68000APL*PLUSAPL.jlAPL.SVAPLXExtended Dyalog APLIverson notationIVSYS/7090NARSngn/aplopenAPLOperators and FunctionsPATRowanSAXSHARP APLRationalized APLVisualAPL (APLNext) ∙ VS APLYork APL
Derivatives AHPLBQNCoSyELIGleeIIvyJJellyK (Goal, Klong, Q) ∙ KamilaLispLang5LilNialRADUiua
Overviews Comparison of APL dialectsTimeline of array languagesTimeline of influential array languagesFamily tree of array languages