slige/examples/generic_array.slg

33 lines
730 B
Plaintext
Raw Normal View History

2024-12-26 03:56:59 +01:00
//
2024-12-26 02:38:32 +01:00
//fn print(msg: string) #[builtin(Print)] {}
//fn println(msg: string) { print(msg + "\n") }
//
//fn itos(number: int) -> string #[builtin(IntToString)] {}
//
//fn array_new<T>() -> [T] #[builtin(ArrayNew)] {}
//fn array_push<T>(array: [T], value: T) #[builtin(ArrayPush)] {}
//fn array_length<T>(array: [T]) -> int #[builtin(ArrayLength)] {}
//fn array_at<T>(array: [T], index: int) -> T #[builtin(ArrayAt)] {}
2024-12-26 02:38:32 +01:00
fn main() {
let strings = array_new::<string>();
2024-12-26 03:56:59 +01:00
array_push(strings, "hello");
array_push(strings, "world");
2024-12-26 02:38:32 +01:00
let ints = array_new::<int>();
2024-12-26 03:56:59 +01:00
array_push(ints, 1);
array_push(ints, 2);
for v in strings {
println(v)
}
for v in ints {
println(itos(v))
}
2024-12-26 02:38:32 +01:00
}