APL syntax: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>RikedyP
Miraheze>Adám Brudzewsky
No edit summary
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 ==
Line 28: Line 30:
<pre class="language-apl">
<pre class="language-apl">
</pre>
</pre>
== Scoping rules ==
=== Functions ===
=== Operators ===
{{APL programming language}}

Revision as of 09:17, 20 September 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


Scoping rules

Functions

Operators

Template:APL programming language