APL syntax: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>RikedyP
(Created page with "APL's core syntactic principles are: * Arrays as first class citizens * Functions take arrays as input and produce arrays as output * Operators take functions...")
 
Miraheze>RikedyP
Line 17: Line 17:
     ∇   
     ∇   
</pre>
</pre>
{{Works in|[[Dyalog APL]] [[APL2]] [[GNU APL]] [[NARS2000]]}}
{{Works in|[[Dyalog APL]], [[APL2]], [[GNU APL]], [[NARS2000]]}}


== Example operator definition ==
== Example operator definition ==

Revision as of 11:28, 19 September 2019

APL's core syntactic principles are:

  • Arrays as first class citizens
  • Functions take arrays as input and produce arrays as output
  • Operators take functions as operands and produce derived functions

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