|
|
|
|
|
by wyager
3627 days ago
|
|
Tail recursion can't use constant space if it's strictly generating another data structure of the same size. That doesn't even make sense. Interesting fact about foldl'. Regardless, in practice it is strict and tail recursive. As I mentioned earlier, this does not mean the same thing as constant space unless the reduction function returns a fixed size result. Yes, you can guarantee that a linked list in Java is finite because Java does not support codata. Haskell's tail call recursion is also often optimized to be allocation-free, unless, again, it is generating some data structure. |
|
What about another thread running that keeps generating pieces to the end of the linked list? (No problem, with mutation.)