Look at the Go homepage. Or Nim. (But not Rust sadly.)
function fib(a)
return countfib(1,1,a)
end
function countfib(a,b,n)
if n == 1 then
return a
else
-- proper tail call
return countfib(b,a+b,n-1)
end
end
print(fib(6)) --> 8either way, at least you can't toggle between indexes starting at zero and one, (at least not that i can recall.)
You can, you just have to explicitly assign something to a[0]. Lua doesn't have real arrays, just tables. You have to do it for every table you use/define though, so if you mean "toggle" as in change the default behavior everywhere then I believe you are correct.
In Lua you specify the “beginning” and “end” of the iteration, both included. It doesn’t work like in C, where you have an initialization and an invariant. What makes it short in C would make it longer in Lua, and viceversa.
You could argue “why not make loops like C”, then. But that can be extended to the limit: “why have a different language at all?”.