mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 13:06:30 +00:00
39 lines
816 B
Plaintext
39 lines
816 B
Plaintext
fn print(msg: string) #[builtin(Print)] {}
|
|
fn println(msg: string) { print(msg + "\n") }
|
|
|
|
fn array_length_int(array: [int]) -> int #[builtin(ArrayLength)] {}
|
|
fn array_new_int() -> [int] #[builtin(ArrayNew)] {}
|
|
fn array_push_int(array: [int], value: int) #[builtin(ArrayPush)] {}
|
|
|
|
fn int_to_string(number: int) -> string #[builtin(IntToString)] {}
|
|
|
|
fn add(a: int, b: int) -> int {
|
|
a + b
|
|
}
|
|
|
|
fn main() -> int {
|
|
let result = 0;
|
|
let array = array_new_int();
|
|
|
|
let i = 0;
|
|
loop {
|
|
if i >= 10 {
|
|
break;
|
|
}
|
|
|
|
array_push_int(array, i);
|
|
i = i + 1;
|
|
}
|
|
i = 0;
|
|
loop {
|
|
if i >= array_length_int(array) {
|
|
break;
|
|
}
|
|
result = add(array[i], array[i]);
|
|
println(int_to_string(result));
|
|
i = i + 1;
|
|
}
|
|
result
|
|
}
|
|
|