John
421aab3aa2
My editor's performance was tanking because of macro interpreter::builtins::builtin! Temporary solution: move the interpreter into a separate crate If I intended to keep the interpreter around, in the long-term, it might be an idea to make a proc-macro for builtin expansion. However, the only reason I need the macros is because the interpreter's dynamic typing implementation is so half-baked. After I bang out the new type checker/inference engine, I'll have to rewrite the entire interpreter anyway!
17 lines
282 B
Rust
17 lines
282 B
Rust
// Calculate Fibonacci numbers
|
|
|
|
fn main() {
|
|
for num in 0..=30 {
|
|
println!("fib({num}) = {}", fib(num))
|
|
}
|
|
}
|
|
|
|
/// Implements the classic recursive definition of fib()
|
|
fn fib(a: i64) -> i64 {
|
|
if a > 1 {
|
|
fib(a - 1) + fib(a - 2)
|
|
} else {
|
|
1
|
|
}
|
|
}
|