4,494
edits
m (Text replacement - "</source>" to "</syntaxhighlight>") Tags: Mobile edit Mobile web edit |
|||
Line 19: | Line 19: | ||
Additionally, there are some syntactic elements that cannot be used as values: | Additionally, there are some syntactic elements that cannot be used as values: | ||
* The assignment arrow <source lang=apl inline>←</ | * The assignment arrow <source lang=apl inline>←</syntaxhighlight> | ||
* Square brackets <source lang=apl inline>[]</ | * Square brackets <source lang=apl inline>[]</syntaxhighlight> used for [[bracket indexing]] and [[function axis]] specification | ||
* Parentheses <source lang=apl inline>()</ | * Parentheses <source lang=apl inline>()</syntaxhighlight> for grouping | ||
* The Diamond <source lang=apl inline>⋄</ | * The Diamond <source lang=apl inline>⋄</syntaxhighlight> and newline characters used as a [[statement separator]] | ||
* The [[Del]] character <source lang=apl inline>∇</ | * The [[Del]] character <source lang=apl inline>∇</syntaxhighlight> used for [[tradfn]]s, or curly braces for [[dfn]]s | ||
* [[Keyword]]s for [[control structure]]s | * [[Keyword]]s for [[control structure]]s | ||
* The [[branch]] arrow <source lang=apl inline>→</ | * The [[branch]] arrow <source lang=apl inline>→</syntaxhighlight> | ||
The second group, consisting of fixed syntax written with particular tokens, is common to many programming languages (in fact, APL tends to have a simpler fixed syntax than many contemporary languages). However, the first group is unusual because it means that a variable's syntactic properties are determined by the variable's value and not just by how it's written. This property makes it impossible to parse an APL statement with variables in general: for example, the statement <source lang=apl inline>a b c</ | The second group, consisting of fixed syntax written with particular tokens, is common to many programming languages (in fact, APL tends to have a simpler fixed syntax than many contemporary languages). However, the first group is unusual because it means that a variable's syntactic properties are determined by the variable's value and not just by how it's written. This property makes it impossible to parse an APL statement with variables in general: for example, the statement <source lang=apl inline>a b c</syntaxhighlight> could be a function application, two function applications, a function modified by an operator, and so on. | ||
== Example array definitions == | == Example array definitions == | ||
Line 33: | Line 33: | ||
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 | ||
</ | </syntaxhighlight> | ||
== Example function definition == | == Example function definition == | ||
Line 41: | Line 41: | ||
[2] r←l r | [2] r←l r | ||
∇ | ∇ | ||
</ | </syntaxhighlight> | ||
{{Works in|[[Dyalog APL]], [[APL2]], [[GNU APL]], [[NARS2000]]}} | {{Works in|[[Dyalog APL]], [[APL2]], [[GNU APL]], [[NARS2000]]}} | ||
Line 49: | Line 49: | ||
[1] r←(PreProc larg)Main(PreProc rarg) | [1] r←(PreProc larg)Main(PreProc rarg) | ||
∇ | ∇ | ||
</ | </syntaxhighlight> | ||
== Example function application == | == Example function application == | ||
<source lang=apl> | <source lang=apl> | ||
Line 60: | Line 60: | ||
2+/1 2 3 4 ⍝ Infix primitive derived function | 2+/1 2 3 4 ⍝ Infix primitive derived function | ||
3 5 7 | 3 5 7 | ||
</ | </syntaxhighlight> | ||
== Scoping rules == | == Scoping rules == |