Edit: I'm apparently blind. Sorry! And thanks to those who answered anyway.
Apologies in advance if this is sort of a nitpicky question, but I'm generally very paranoid that I don't fully understand how Mathematica functions are behaving "under the hood." The documentation of Fold seems only to address cases of the form
Fold[f, a, {x1, x2, ...}]
i.e. where the head of the third argument is List
, and expresses the result as
f[... f[f[a, x1], x2], ...].
However, I've noticed that it actually appears that the result of
Fold[f, a, h[x1 ,x2, ...]]
appears to be identical to the one where h
is List
in all cases that I've tested. This isn't really surprising at all, at least in the sense that it seems totally consistent with the general philosophy behind how Mathematica functions behave (there are countless other examples where functions are explicitly documented as handling arbitrary heads in the same way they handle List
) -- after all, extracting a Part
of any expression h[...]
does not depend on the head h
-- but usually in such cases this is pointedly mentioned at least once somewhere in the documentation. I want to make sure I'm not missing some other reason why Fold
would behave like this (or that I'm not somehow missing where this is addressed in the documentation).
Thanks!