E-on-Java 0.9.3
Version of implementation E-on-Java of programming language EA version of E-on-Java interpreter.
Links:
Examples:
Hello, World! - E (479):
println("Hello, World!")
Fibonacci numbers - E (480):
var 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 - E (481):
E 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
]]>