18
$\begingroup$

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?

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

This is an answer generated from the comments.

D. Lichtblau:

Introduced in either version 3 or 4, I forget which. Not sure if it has changed since then.

Mr.Wizard:

Since this is a longstanding feature is there a reason it has not been documented?

D. Lichtblau:

It is not really the most carefully designed of features. (Or so claims the developer who put it in 20 or so years ago.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.