4,506
edits
m (Text replacement - "</source>" to "</syntaxhighlight>") Tags: Mobile edit Mobile web edit |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
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 < | * The assignment arrow <syntaxhighlight lang=apl inline>←</syntaxhighlight> | ||
* Square brackets < | * Square brackets <syntaxhighlight lang=apl inline>[]</syntaxhighlight> used for [[bracket indexing]] and [[function axis]] specification | ||
* Parentheses < | * Parentheses <syntaxhighlight lang=apl inline>()</syntaxhighlight> for grouping | ||
* The Diamond < | * The Diamond <syntaxhighlight lang=apl inline>⋄</syntaxhighlight> and newline characters used as a [[statement separator]] | ||
* The [[Del]] character < | * The [[Del]] character <syntaxhighlight 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 < | * The [[branch]] arrow <syntaxhighlight 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 < | 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 <syntaxhighlight 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 == | ||
< | <syntaxhighlight 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 | ||
Line 36: | Line 36: | ||
== Example function definition == | == Example function definition == | ||
< | <syntaxhighlight lang=apl> | ||
∇ r←l Tradfn r | ∇ r←l Tradfn r | ||
[1] ⍝ An infix (dyadic) tradfn | [1] ⍝ An infix (dyadic) tradfn | ||
Line 45: | Line 45: | ||
== Example operator definition == | == Example operator definition == | ||
< | <syntaxhighlight 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) | ||
Line 51: | Line 51: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Example function application == | == Example function application == | ||
< | <syntaxhighlight lang=apl> | ||
÷3 ⍝ Prefix primitive function | ÷3 ⍝ Prefix primitive function | ||
0.3333333333 | 0.3333333333 |