ELI (programming language): Difference between revisions

Content deleted Content added
Rescuing 0 sources and tagging 1 as dead.) #IABot (v2.0
m change source to syntaxhighlight
Line 49:
 
Exclamation point (!) is an interval function. It can generate a vector of n integer from 1 to n.
<sourcesyntaxhighlight lang="text">
!10
1 2 3 4 5 6 7 8 9 10
</syntaxhighlight>
</source>
The execution order of ELI is from right to left, and all primitive functions have equal precedence.
<sourcesyntaxhighlight lang="text">
5 * 2 + 10 // from right to left, 5 * (2 + 10)
60
</syntaxhighlight>
</source>
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.
<sourcesyntaxhighlight lang="text">
{add: x+y} // short function form
add
Line 66:
1 add !10 // 1+(1..10)
2 3 4 5 6 7 8 9 10 11
</syntaxhighlight>
</source>
The <code>$</code> rotation operator returns the reverse order of a vector.
<sourcesyntaxhighlight lang="text">
$!10 // reverse
10 9 8 7 6 5 4 3 2 1
</syntaxhighlight>
</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>.
<sourcesyntaxhighlight lang="text">
2 3#!6 // 2 dimension array (matrix)
1 2 3
4 5 6
</syntaxhighlight>
</source>
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.
<sourcesyntaxhighlight lang="text">
x <- !20 // 1..20
x
Line 85:
(1 = 2|x) / x // get odd numbers from x
1 3 5 7 9 11 13 15 17 19
</syntaxhighlight>
</source>
 
==File extensions==
Line 93:
An ELI file with extension <code>.esf</code> is a script file which contains all methods and data. A simple way to create a script file is using the command <code>)out</code>. However, a clean workspace with no debugging or error information left is needed before a script file can be created. Later the command <code>)fload</code> can be used to reload the script file.
 
<sourcesyntaxhighlight lang="text">
)out MyScript
)lib
Line 99:
)fload MyScript
saved 2017.02.17 10:23:55 (gmt-5)
</syntaxhighlight>
</source>
 
An ELI file with extension <code>.eli</code> is an ELI workspace file which contains everything in a workspace. <code>save</code> and <code>load</code> are commands for workspace files.
 
<sourcesyntaxhighlight lang="text">
)save MyWorkspace
)load MyWorkspace
saved 2017.02.17 10:57:19 (gmt-5)
</syntaxhighlight>
</source>
 
==References==