61 lines
No EOL
755 B
Text
61 lines
No EOL
755 B
Text
|
|
print "native function";
|
|
|
|
print clock();
|
|
|
|
fun count(n) {
|
|
if (n > 1) count(n - 1);
|
|
print n;
|
|
}
|
|
|
|
count(10);
|
|
|
|
fun hi(name, surname) {
|
|
print "hello, " + name + " " + surname + "!";
|
|
}
|
|
|
|
hi("John", "Doe");
|
|
|
|
|
|
fun re(turn) {
|
|
print "before return";
|
|
return turn;
|
|
print "should not be printed";
|
|
}
|
|
|
|
print re("turn");
|
|
|
|
|
|
fun sum(start, end) {
|
|
if (start == end) return start;
|
|
return start + sum(start + 1, end);
|
|
}
|
|
|
|
print sum(1, 3);
|
|
|
|
fun fib(n) {
|
|
if (n <= 1) return n;
|
|
|
|
return fib(n - 2) + fib(n - 1);
|
|
}
|
|
|
|
for (var i = 1; i <= 10; i = i + 1) {
|
|
print fib(i);
|
|
}
|
|
|
|
|
|
fun makeCounter() {
|
|
var i = 0;
|
|
|
|
fun incr() {
|
|
i = i + 1;
|
|
print i;
|
|
}
|
|
|
|
return incr;
|
|
}
|
|
|
|
var counter = makeCounter();
|
|
|
|
counter();
|
|
counter(); |