Content deleted Content added
Change mirror site |
m Clearer format |
||
Line 44:
A line of ELI executes from right to left as a chain of operations; anything to the right of ‘//’ is a comment.
Exclamation point (!) is an '''interval''' function. It can generate a vector of n integer from 1 to n.▼
<source lang="text">
!10
1 2 3 4 5 6 7 8 9 10
</source>
The execution order of ELI is from right to left and all primitive functions have '''equal precedence'''.▼
▲Exclamation point (!) is an '''interval''' function. It can generate a vector of n integer from 1 to n.
<source lang="text">
5 * 2 + 10 // from right to left, 5 * (2 + 10)
60
</source>
In next example a function <code>add</code> is declared in a short function form. Then, the arguments of the function can take either a scalar or a vector.
▲The execution order of ELI is from right to left and all primitive functions have '''equal precedence'''.
<source lang="text">
{add: x+y} // short function form
Line 62 ⟶ 63:
2 3 4 5 6 7 8 9 10 11
</source>
<source lang="text">
$!10 // reverse
10 9 8 7 6 5 4 3 2 1
</source>
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>.▼
<source lang="text">
2 3#!6 // 2 dimension array (matrix)
Line 73 ⟶ 74:
4 5 6
</source>
▲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>.
<source lang="text">
x <- !20 // 1..20
Line 81 ⟶ 82:
1 3 5 7 9 11 13 15 17 19
</source>
▲The <code>x</code> is assigned with a vector from 1 to 20. <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.
==References==
|