Re: Conversion of Orderless functions to non Orderless one

*To*: mathgroup at smc.vnet.net*Subject*: [mg24107] Re: [mg24046] Conversion of Orderless functions to non Orderless one*From*: Daniel Lichtblau <danl at wolfram.com>*Date*: Tue, 27 Jun 2000 00:51:59 -0400 (EDT)*References*: <200006210620.CAA10924@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

zhl67 at hotmail.com wrote: > > Hi, there > > My question might be silly to somebody out there but it really bothers > me: Is there any way to convert an orderless function into non > orderless ones for a certain range of arguments? > > For instance, let's say have a set Operators: > > Operators={a,b,c} > > What I wanted to do is that whenever expressions like Times[b,a,c] is > entered, the outcome should look like b**a**c (i.e. Times turned into > NonCommutativeMultiply). The special requirement is that this change > happens only for members of the set Operators (otherwise I can just > ClearAttributes[Times,Orderless] ), and that the output keeps the order > of the input argument, i.e. it should be b**a**c, NOT a**b**c. Could > anyone help the case? > > Liu Zhao > Univ. York, UK > > Sent via Deja.com http://www.deja.com/ > Before you buy. Rather than mess with Times, you could make a function that separates the factors into noncommuting and commuting variables. Below is an example of how this might be done. In[6] := operators = {a, b, c}; In[7] := myMultiply[nclist_List, x__] := Module[{j, fax = {x}, len, comm = {}, noncomm = {}}, len = Length[fax]; For[j = 1, j <= len, j++, fac = fax[[j]]; If[MemberQ[nclist, fac], noncomm = {noncomm, fac}, comm = {comm, fac}];]; Apply[Times, Flatten[comm]]* Apply[NonCommutativeMultiply, Flatten[noncomm]]] In[8] := myMultiply[operators, q, r, s, b, t, y, a, x, w, q, c, d, f] 2 Out[8] = d f q r s t w x y b ** a ** c Daniel Lichtblau Wolfram Research

**References**:**Conversion of Orderless functions to non Orderless one***From:*zhl67@hotmail.com