(no title)
Willamin | 2 years ago
The description of the Fibonacci example seems incorrect, but I might be misunderstanding something about the language.
> A fib evaluation function was defined using recursion.
> The result of the function call was assigned to a variable named "result" and format the output using fmt.printf
import fmt
fn fib(int n):int {
if n <= 1 {
return n
}
return fib(n - 1) + fib(n - 2)
}
fmt.printf('fib result is %d', fib(30))
No variable named "result" is ever defined, right? Maybe the description is outdated from a time when an intermediate variable was present.
weiwenhao|2 years ago
ozfive|2 years ago
weiwenhao|2 years ago
2023throwawayy|2 years ago
i-use-nixos-btw|2 years ago
unfunco|2 years ago
unknown|2 years ago
[deleted]