spooky/examples/sample.spooky

27 lines
350 B
Plaintext
Raw Permalink Normal View History

2026-04-29 15:50:03 +00:00
struct Point {
int x;
int y;
};
2026-04-29 18:56:41 +00:00
fn sum_array(arr: int[]) -> int {
let mut total = 0;
2026-04-29 15:50:03 +00:00
foreach (int n in arr) {
total = total + n;
}
return total;
}
2026-04-29 18:56:41 +00:00
fn main() -> int {
let p: Point;
let nums: int[];
let mut x = 1 + 2 * 3;
2026-04-29 15:50:03 +00:00
p.x = x;
if (x > 0) {
x = x + p.x;
} else {
x = 0;
}
x = sum_array(nums);
return x;
}