3 ms·
A bit of a nitpick on the language on the homepage: The description of the Fibonacci example seems incorrect, but I might be misunderstanding something about t
by Willamin 3y ago
A bit of a nitpick on the language on the homepage:
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.
- 2023throwawayy 3y agoThis will also never do anything if you pass it 0.
- i-use-nixos-btw 3y agoLook at the if statement again.
- unfunco 3y agoIt'll return 0.
- deleted 3y ago[deleted]
- weiwenhao 3y agoThank you for pointing out the bug in the website description; I have now updated it.
- ozfive 3y agoYou are absolutely correct, while reading through it I was becoming increasingly concerned that whomever wrote the description was the language writer themselves. I expect a level of attention to detail from someone who is writing their own language.
- weiwenhao 3y agoThank you for the heads-up! I'll be more careful with the details in the future. I am sorry about that, because all the current English documentation has been translated by GPT-4. It seems I wasn't fully prepared, but I'm still thrilled that someone shared the Nature project on Hacker News.