ELI (programming language): Difference between revisions

Content deleted Content added
FrescoBot (talk | contribs)
m Bot: link syntax and minor changes
m File extensions: <syntaxhighlight lang="q">
 
(45 intermediate revisions by 22 users not shown)
Line 1:
{{Multiple issues|
{{COI|date=April 2017}}
{{Notability|date=April 2017}}
{{Primary sources|date=April 2017}}
}}
{{Infobox programming language
|name = ELI<ref name="vector">
[http://archive.vector.org.uk/art10501180 ELI: a simple system for array programming]</ref>
|logo =
|paradigm = [[arrayArray programming|array]]
|year = 2011
|designer = Wai-Mee Ching
|developer = RapidsoftHanfeng Chen<ref name="fastarraymirror">[http://fastarraywww.appspotsable.commcgill.ca/default~hanfeng.htmlc/eli/ ELI - officialmirror site in the Sable lab at McGill University]</ref> (Hanfeng ChenRapidsoft)
|released = {{Start date and age|2011}}
|latest release version = 0.2
|latest release dateversion = November 30, 20130.3
|latest release date = {{Start date and age|2015|08|10}}
|typing = [[dynamic typing|dynamic]]
|programming language = [[C++]], [[Qt (software)|Qt]]
|implementations = C++
|platform = [[IA-32]], [[x86-64]]
|dialects =
|operating system = [[Cross-platform]]: [[Windows]], [[Linux]], [[macOS]]
|influenced_by = [[APL (programming language)|APL]], [[Q (programming language from Kx Systems)|Q]]
|license = [[Freeware]]
|file ext = .esf .eli
|website = {{URL|fastarray.appspot.com}}
|implementations =
|dialects =
|influenced by = [[APL (programming language)|APL]], [[Q (programming language from Kx Systems)|Q]]
}}
 
'''ELI'''<ref name="website">{{cite web |url=https://fastarray.appspot.com/ |title=ELI: A System for Programming with Arrays |website=Disqus}}</ref> is an interactive [[array programming]] language system based on the [[programming language]] [[APL (programming language)|APL]]. It has the most of functionalitiesthe functions of ISOthe APL[[International standard.Organization Infor additionStandardization]] to classical(ISO) APL standard ''ISO/IEC 13751:2001'', ELIand featuresalso list for non-homogeneous or non-rectangular data, complex numbers, symbols, temporal data, and control structures. A scripting file facility helpsis a useravailable to easily organize programs in a fashion similar to using <code>#include</code> in [[C (programming language)|C]], which also provides convenient data [[input/output]]. Moreover, ELI has dictionaries, tables, and a basic set of [[SQL]]-like statements. For performance, ELIit offershas a [[compiler]] restricted to flat array programs.
 
By replacing each [[APL syntax and symbols|APL character]] with one or two [[ASCII]] characters, ELI retains APL’sAPL's succinct and expressive way of doing array programming, i.e. compared with [[MATLAB]] or [[Python (programming language)|Python]], ELI encourages a [[dataflow programming]] style of programming, where the output of one operation feeds the input of another that results in greater productivity and clarity of code.
 
ELI is available without charge, as [[freeware]], on [[Windows]], [[Linux]], and [[macOS]].
ELI is free and available on Windows, Linux and Mac OS. The following is a sample to illustrate the flavor of the language which incidentally shows that ELI is easy to learn and free of unnecessary syntactic clutters. A line of ELI executes from right to left as a chain of operations; anything to the right of ‘//’ is a comment.
 
==Version 0.3==
<pre>
ELI version 0.3, described as a stable release, was released on August 10, 2015. It integrates with a cross-platform IDE, ELI Studio, which provides a code editor with specialized functions to write and load ELI code. Three added widgets are used to monitor functions, variables, libraries and command history.
!10 //get the vector 1..10
 
Version 0.3 adds several new features.<ref>{{cite web |url=https://fastarray.appspot.com/releasenote/Eli-v0.3.html |title=Overview |last=Chen |first=Hanfeng |date=2015 |website=ELI, a System for Programming with Arrays |publisher=Fastarray.appspot.com |access-date=26 February 2018}}</ref>
* Like: string match
* Match
* []PP: printing precision control
* )time: performance measure
* []: standard input
* Date and time attributes
* File handle: []open, []close, []write, and []get
* Semicolon (;)
 
==Example code==
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.
<syntaxhighlight lang="text">
!10
1 2 3 4 5 6 7 8 9 10
</syntaxhighlight>
100*!10 //multiply that vector by 100
The execution order of ELI is from right to left, and all primitive functions have equal precedence.
100 200 300 400 500 600 700 800 900 1000
<syntaxhighlight lang="q">
3 4#!10 //reshape the vector 1..10 into a 3x4 matrix
5 * 2 + 10 // from right to left, 5 * (2 + 10)
1 2 3 4
60
5 6 7 8
</syntaxhighlight>
9 10 1 2
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.
&.3 4#!10 //flip the above matrix
<syntaxhighlight lang="q">
1 5 9
{add: x+y} // short function form
2 6 10
add
3 7 1
1 add 2 // 1+2
4 8 2
3
+/3 4#!10 //sum each row of the 3x4 matrix
1 add !10 // 1+(1..10)
10 26 22
2 3 4 5 6 7 8 9 10 11
</syntaxhighlight>
2*0,!10 //append 0 in front of 1..10, and double it
The <code>$</code> rotation operator returns the reverse order of a vector.
0 2 4 6 8 10 12 14 16 18 20
<syntaxhighlight lang="q">
2*.0,!10 //2 to the power of 0..10
1 2 4 8 16 32 64$!10 128 256 512 1024 // reverse
10 9 8 7 %1 2 36 5 104 3 //1 divided by2 1 2 3 5 10
</syntaxhighlight>
1 0.5 0.3333333333 0.2 0.1
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>.
1024*.%1 2 3 5 10 //1024 takes 1 root, square root, cube root, …
<syntaxhighlight lang="q">
1024 32 10.0793684 4 2
2 3#!6 // 2 dimension array (matrix)
1 2 3
1-2 //1 minus 2
4 5 6
_1
</syntaxhighlight>
_1*.0.5 //square root of minus 1
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.
0j1
<syntaxhighlight lang="q">
@1
3.141592654 x <- !20 //pi 1..20
*.0j1*@1 //eiΠ = -1x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
_1
(1 = 2|x) / x // get odd numbers from x
1 3 5 7 9 11 13 15 17 19
</syntaxhighlight>
 
==File extensions==
2012.12.25+!7 //7 days following Christmas of 2012
2012.12.26 2012.12.27 2012.12.28 2012.12.29 2012.12.30 2012.12.31 2013.01.01
w<-10?.100 //get 10 random numbers from 1..100
w
14 76 46 54 22 5 68 94 39 52
w<50 //compare w with 50
1 0 1 0 1 1 0 0 1 0
(w<50)/w //select elements in w which are less than 50
14 46 22 5 39
+\(w<50)/w //partial sums of the vector above
14 60 82 87 126
 
Two file extensions are used in ELI for exchanging and sharing code for different purposes: <code>.esf</code> and <code>.eli</code>.
$_3+!12 //reverse of _3 adds to 1..12
9 8 7 6 5 4 3 2 1 0 _1 _2
32+1.8*c<-$_2+!12 //Fahrenheit correspond to Celsius above
48.2 46.4 44.6 42.8 41 39.2 37.4 35.6 33.8 32 30.2 28.4
c,[1.5]32+1.8*c<-$_3+!12 //a table of temperature conversion
9 48.2
8 46.4
7 44.6
6 42.8
5 41
4 39.2
3 37.4
2 35.6
1 33.8
0 32
_1 30.2
_2 28.4
 
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.
(2 3#!6;`ny `ma `md;'ABCDE') //a list of numbers, symbols, chars
<1 2 3
4 5 6
<`ny `ma `md
<ABCDE
#"(2 3#!6;`ny `ma `md;'ABCDE') //shape of each element in the list
<2 3
<3
<5
 
<syntaxhighlight lang="text">
</pre>
)out MyScript
)lib
MyScript.esf
)fload MyScript
saved 2017.02.17 10:23:55 (gmt-5)
</syntaxhighlight>
 
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.
 
<syntaxhighlight lang="q">
)save MyWorkspace
)load MyWorkspace
saved 2017.02.17 10:57:19 (gmt-5)
</syntaxhighlight>
 
==References==
{{reflistReflist}}
 
==SeeExternal alsolinks==
* {{Official website|fastarray.appspot.com}}
* [[APL (programming language)|APL]] - the first array programming language
* [https://fastarray.appspot.com/docs/ Online documentation]{{Dead link|date=December 2019 |bot=InternetArchiveBot |fix-attempted=yes}}
* [[J (programming language)|J]] - another APL-inspired language
* [https://www.youtube.com/channel/UCpq4XRc7A1YNbEnBRx9-jzw YouTube channel]
* [[Q (programming language from Kx Systems)|Q]] - Q (programming language from Kx Systems)
 
{{APL programming language}}
 
[[Category:Array programming languages]]
[[Category:APL programming language family]]
[[Category:Array programming languages]]