In the documentation for fold, it says
Fold[f,x,list] gives the last element of FoldList[f,x,list].
But this is surely not the way it is implemented, right? In those cases where each step of the Fold returns a large object, it would be a huge waste of memory to actually store the whole list and then just pick the last element at the end.
How can I test this? Does Trace work as advertised, or does it skip printing intermediate steps sometimes?


TracePrint[Fold[f, a, Range[4]]]. – J. M.♦ Aug 19 '12 at 17:26Why You Do Not Usually Need to Know about Internalsreference.wolfram.com/mathematica/tutorial/… – Nasser Aug 19 '12 at 19:47