APL syntax: Difference between revisions
Jump to navigation
Jump to search
Miraheze>RikedyP |
m (7 revisions imported: Migrate from miraheze) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 7: | Line 7: | ||
== Example array definitions == | == Example array definitions == | ||
< | <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 | ||
</ | </source> | ||
== Example function definition == | == Example function definition == | ||
< | <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 | ||
∇ | ∇ | ||
</ | </source> | ||
{{Works in|[[Dyalog APL]], [[APL2]], [[GNU APL]], [[NARS2000]]}} | {{Works in|[[Dyalog APL]], [[APL2]], [[GNU APL]], [[NARS2000]]}} | ||
== Example operator definition == | == Example operator definition == | ||
< | <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) | ||
∇ | ∇ | ||
</ | </source> | ||
== Example function application == | == Example function application == | ||
< | <source lang=apl> | ||
÷3 ⍝ Prefix primitive function | ÷3 ⍝ Prefix primitive function | ||
0.3333333333 | 0.3333333333 | ||
Line 37: | Line 37: | ||
2+/1 2 3 4 ⍝ Infix primitive derived function | 2+/1 2 3 4 ⍝ Infix primitive derived function | ||
3 5 7 | 3 5 7 | ||
</ | </source> | ||
== Scoping rules == | == Scoping rules == | ||
Line 45: | Line 45: | ||
=== Operators === | === Operators === | ||
{{APL | {{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+Win ∙ APL2 ∙ APL64 ∙ APL\iv ∙ Aplette ∙ April ∙ Co-dfns ∙ Dyalog APL ∙ Dyalog APL Vision ∙ dzaima/APL ∙ GNU APL ∙ Kap ∙ NARS2000 ∙ Pometo |
Historical | A Programming Language ∙ A+ (A) ∙ APL# ∙ APL2C ∙ APL\360 ∙ APL/700 ∙ APL\1130 ∙ APL\3000 ∙ APL.68000 ∙ APL*PLUS ∙ APL.jl ∙ APL.SV ∙ APLX ∙ Extended Dyalog APL ∙ Iverson notation ∙ IVSYS/7090 ∙ NARS ∙ ngn/apl ∙ openAPL ∙ Operators and Functions ∙ PAT ∙ Rowan ∙ SAX ∙ SHARP APL ∙ Rationalized APL ∙ VisualAPL (APLNext) ∙ VS APL ∙ York APL |
Derivatives | AHPL ∙ BQN ∙ CoSy ∙ ELI ∙ Glee ∙ I ∙ Ivy ∙ J ∙ Jelly ∙ K (Goal, Klong, Q) ∙ KamilaLisp ∙ Lang5 ∙ Lil ∙ Nial ∙ RAD ∙ Uiua |
Overviews | Comparison of APL dialects ∙ Timeline of array languages ∙ Timeline of influential array languages ∙ Family tree of array languages |