3 ms·
The author mentions that the recursive way is harder to code in .net, but I wonder if this were reimplemented in F# which supports tail-recursion if that caveat
by chusk3 8y ago
The author mentions that the recursive way is harder to code in .net, but I wonder if this were reimplemented in F# which supports tail-recursion if that caveat would disappear. Also be interesting to see how this implementation compares/contrasts with data structures over in https://github.com/fsprojects/FSharpx.Collections https://github.com/fsprojects/FSharpx.Collections
- adyavanapalli 8y agoThe author says the opposite: "The non-recursive way is more efficient as the CLR does not have to keep pushing and popping its call stack (which is quite slow). The non-recursive way is unfortunately harder to code. So the challenge was on!"
- Rizz 8y agoThat's what the tail call optimization is for, it optimizes the recursive function into a loop.