2022-08-17 17:31:15 +02:00
|
|
|
operator `<`(a, b: int): bool {
|
|
|
|
#pragma[magic: "LessThan", pure]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
operator `+`(a, b: int): int {
|
|
|
|
#pragma[magic: "Add", pure]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
operator `-`(a, b: int): int {
|
|
|
|
#pragma[magic: "Subtract", pure]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
operator `-`(a, b: float): float {
|
|
|
|
#pragma[magic: "SubtractFloat64", pure]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn clock: float {
|
|
|
|
#pragma[magic: "SysClock64"]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn print(x: int) {
|
|
|
|
#pragma[magic: "PrintInt64"]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn print(x: float) {
|
|
|
|
#pragma[magic: "PrintFloat64"]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn print(x: string) {
|
|
|
|
#pragma[magic: "PrintString"]
|
|
|
|
}
|
2022-08-14 18:37:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
fn fib(n: int): int {
|
|
|
|
if n < 2 {
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
return fib(n - 2) + fib(n - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-17 17:31:15 +02:00
|
|
|
print("Computing the value of fib(30)");
|
2022-08-14 18:37:06 +02:00
|
|
|
var x = clock();
|
2022-08-17 17:31:15 +02:00
|
|
|
print(fib(30));
|
2022-08-14 18:37:06 +02:00
|
|
|
print(clock() - x);
|
2022-08-15 19:07:06 +02:00
|
|
|
print("Done!");
|