See Installation
Scant, but progressing: https://nallantli.github.io/Rossa/#/
Hello World:
putln("Hello World!");
Factorial:
fn fact(x) {
if x > 1 then {
return x * fact(x - 1);
} else {
return 1;
}
}
putln(fact(5)); # 120
Fibonacci Sequence:
fn fib(ref size: Number) {
array := [0, 1] ++ alloc(size - 2);
for i in 2 .. size do {
array[i] = array[i - 1] + array[i - 2];
}
return array;
}
fib(20).map(fn(e, i) putln("{0}:\t{1}" & [i, e]));
FizzBuzz:
for i in 1 <> 100 do {
if i % 3 == 0 && i % 5 == 0 then {
putln("FizzBuzz");
} elif i % 3 == 0 then {
putln("Fizz");
} elif i % 5 == 0 then {
putln("Buzz");
} else {
putln(i);
}
}
Basic File/Folder Output:
(Note that the /
operator is overloaded in class Path
)
load "fs";
p := new Path();
p = p / "Example";
if !p.exists() then {
p.mkdirs();
}
io := new FileIO(p / "example.txt");
io.write("Hello World");
io.close();
Threading:
load "Thread"
fn f(ref x: Number, ref id: Number) {
for i in 0 .. x do {
putln("Thread {0} says {1}" & [id, i]);
}
}
t1 := new Thread(fn()[f] f(10, 1));
t2 := new Thread(fn()[f] f(10, 2));
t1.join();
t2.join();
Making languages
is very fun, but I wish
that it worked well too