3 ms·
> func pow(uint base, uint n): n == 0 ? return 1 : return n * pow(base, n-1) Nitpick: that’s not tail recursive. Something like def pow(base, n, acc=1) = match
by nothrabannosir 1y ago
> func pow(uint base, uint n): n == 0 ? return 1 : return n * pow(base, n-1)
Nitpick: that’s not tail recursive. Something like def pow(base, n, acc=1) = match n case 0 => acc; default => pow(base, n-1, acc*base)
- pyrale 1y agoGiven that `base` is never used, I suspect that's not the only issue :)