How can I more quickly get the interchangeable variables in a function?

Let’s say I have an expression like a b + c d e. This is equal to: a b + c d e, a b + c e d, a b + d c e, a b + d e c, a b + e c d, a b + e d c, b a + c d e, b a + c e d, b a + d c e, b a + d e c, b a + e c d, and b a + e d c

As you can see, swapping a and b will always result in an expression equal to the original expression and swapping c, d, and e will always result in an expression equal to the original expression.

The following code is too slow for more complicated expressions. Is there a speedier way to get Mathematica to give me all equivalence classes of swappable variables such that f[a b + c d e] == {{a, b}, {c, d, e}} for some f?

SwapVariables[expr_, variable1_, variable2_] := expr /. variable1 -> replacedInSwapVariablesFunction /. variable2 -> variable1 /. replacedInSwapVariablesFunction -> variable2;  VariablesIn[expr_] := Integrate`getAllVariables[{expr}, {}];  SwappableVariablesIn[expr_] := (   vars = VariablesIn[expr];   originalVars = vars;   results = {};   While[Length[vars] > 0, (     var = First[vars];     vars = Rest[vars];     swappable = Map[TrueQ[ForAll[originalVars, SwapVariables[expr, var, #] == expr]] &, vars];     results = Append[results, Prepend[Pick[vars, swappable], var]];     vars = Pick[vars, swappable, False];   )];   results );  SwappableVariablesIn[a b + c d e]  (* {{a,b},{c,d,e}} *) 

A function which can be used for a complicated expression to test timing:

DetNByN[n_] := Det[Table[Table[Indexed[x, {i, j}], {j, 1, n}], {i, 1, n}]];  First[Timing[SwappableVariablesIn[DetNByN[6]]]]  (* 10.7118 *) 

Are actions and bonus actions interchangeable?

While I know you can’t cast 2 spells of first level or higher in a turn, and actions can’t just be used as bonus actions, is the reverse true?

Say there’s a barbarian cleric that rages as a bonus action: can they use healing word as an action, when it normally takes a bonus action? Can bonus actions be used as actions in the case of using a bonus for something else such as rage?

How can dash be used as a main action if actions and bonus actions aren’t interchangeable?

I’ve found two twitter chains that I can’t seem to make sense of.

From Jeremy Crawford:

"Actions and bonus actions aren’t interchangeable." [source]

Also from Jeremy Crawford:

"Double dash in one turn can happen with dash as bonus action." [source]

So how can a rogue use both their action and bonus action to dash twice with [Cunning Action]? It is specified in [Cunning Action] that the [Dash] can only be used with a bonus action.

When creating a character spellcasting sheet (level 1 sorcerer), are cantrips seperate from spells or interchangeable?

For example, for the sorcerer class in the list of spells by classes in the handbook, there is a section called “Cantrips (0 level)” as well as the list of 1st level spells. For my four cantrips, can I choose from either list or do I have to choose from the spell list? Thanks in advance.

Is get and post interchangeable?

I know that there are some differences between GET and POST, like descriped in this post on StackOverflow. But what I cannot figure out is, are they interchangable, assuming that you change your code accordingly?

For instance, could you use POST to request HTML-content and display it in the browser? I am not concerned with whether or not this is best practice, only if it is possible.


I should point out, that POST and GET are two different ways of sending HTTP requests. I am aware of this and I am aware that it does makes a difference which one you use. Especially when it comes to security, it is important to know the difference.

What I basically wanted to know was, if it was possible (from a technical point of view) to use POST instead of GET and vice versa. From the answers in this post, it is clear that this is possible to use either. That does not mean that it doesn’t matter which one you use.

Update 2

After much confusion, let me see if I can make this clearer: My understanding is, that all HTTP requests are basically just text strings. Hence the only real difference between GET and POST lies in the interpretaion of that text string. If you changed your HTTP server, you could make it handle GET requests as POST and vice versa. I am aware that this is a horrible idea, with no real usage, I just wanted to know, if my understanding was correct.

What is the best way to clean the sensor on a interchangeable lens camera (mirrorless or digital SLR)?

I’ve got a couple of spots of dust on the sensor of my Canon 20D. A rocket blower isn’t shifting them, and I’m ridiculously scared of some of the more direct methods for cleaning sensors — what methods/systems have you tried, and how successful have they been?