# Undocumented fourth parameter of Collect; how long has it been there?

While tinkering with How to get a list of monomials of a polynomial without coefficients? on a whim I tried a fourth argument in Collect and found:

Collect[(x + y + z + 1)^2, {x, y}, foo, bar]

bar[bar[foo[1 + 2 z + z^2], y foo[2 + 2 z], y^2 foo[1]],
x bar[foo[2 + 2 z], y foo[2]], x^2 bar[foo[1]]]


It seems that in addition to a third parameter that applies to coefficients the fourth parameter takes the place of Plus to reassemble the expression. I also note that this functionality has been present since at least version 7.0.1.

• Is this understanding correct?

• When was this introduced and has it changed any since then?

• Has this been discussed here before?

• What uses might this be put to?

• It's been around since at least V5.2 (2006) and seems unchanged since then. That's as much as I know. – Stefan R Jul 21 '15 at 20:17
• Introduced in either version 3 or 4, I forget which. Not sure if it has changed since then. – Daniel Lichtblau Jul 22 '15 at 3:11
• @Daniel Since this is a longstanding feature is there a reason it has not been documented? – Mr.Wizard Jul 22 '15 at 5:54
• It is not really the most carefully designed of features. (Or so claims the developer who put it in 20 or so years ago.) – Daniel Lichtblau Jul 22 '15 at 14:36