Content deleted Content added
Jerryobject (talk | contribs) WP:REFerence: plain text + inline WP:EXTernal link > WP:CITation, parameters: adds, fills, updates, standardize, conform to master templates. Adds: WP:LINK, Template:Official website. |
m →Example code: <syntaxhighlight lang="q"> |
||
Line 54:
</syntaxhighlight>
The execution order of ELI is from right to left, and all primitive functions have equal precedence.
<syntaxhighlight lang="
5 * 2 + 10 // from right to left, 5 * (2 + 10)
60
</syntaxhighlight>
In the next example a function <code>add</code> is declared in a short function form. The arguments of the function can be either a scalar or a vector.
<syntaxhighlight lang="
{add: x+y} // short function form
add
Line 68:
</syntaxhighlight>
The <code>$</code> rotation operator returns the reverse order of a vector.
<syntaxhighlight lang="
$!10 // reverse
10 9 8 7 6 5 4 3 2 1
</syntaxhighlight>
A 2-by-3 matrix (or higher dimension array, e.g., <code>2 3 4#!24</code>) can be generated by <code>#</code> with left argument <code>2 3</code>.
<syntaxhighlight lang="
2 3#!6 // 2 dimension array (matrix)
1 2 3
Line 79:
</syntaxhighlight>
In first line below the <code>x</code> is assigned with a vector from 1 to 20. Then, <code>1 = 2|x</code> returns odd number <code>True</code> and even number <code>False</code>. The <code>/</code> is a primitive function for compression which '''picks up''' the value in <code>x</code> corresponding to the <code>True</code> values in its left argument.
<syntaxhighlight lang="
x <- !20 // 1..20
x
|