E-on-Java
Implementation of programming language EE interpreter based on Java, one of the two official implementations. It is distributed under Mozilla-compatible license.
Links:
Examples:
Hello, World!:
Example for versions E-on-Java 0.9.3println("Hello, World!")
Fibonacci numbers:
Example for versions E-on-Java 0.9.3var s := [0, 1]
var res := ""
for _ in 1..16 {
def [a, b] := s
s := [b, a + b]
res := res + b.toString(10) + ", "
}
println(res + "...")
Factorial:
Example for versions E-on-Java 0.9.3E is implicitly-typed language; :int
in function signature is not a type declaration but rather a “guard” — a contract which guarantees that factorial
function will be given only integer arguments and it will return only integer values. Such limitations are not necessary but quite useful for code auditing.
def factorial(n :int) :int {
if (n == 0) {
return 1
} else {
return n * factorial(n-1)
}
}
for n in 0..16 {
println(n.toString(10) + "! = " + factorial(n).toString(10))
}
Comments
]]>blog comments powered by Disqus
]]>