I am defining a linear associative multiplication operation Mult[]
:
ClearAll[Mult]
SetAttributes[Mult, {Flat, OneIdentity}];
Mult[A___, a_, B___] := a Mult[A, B] /; NumberQ[a]
Then I try to evaluate a simple expression, which (I believe) does not match the rule written above:
Mult[X, Y]
I got the error Recursion depth of 1024 exceeded
. It is definitely related to the attribute Flat
, but I do not see how. What am I doing wrong?