[Date Index] [Thread Index] [Author Index]
Re: How to get non-printing heads?
Apply[f, expr] or f @@ expr replaces the head of expr by f. (Viz. Help Browser) Tomas Garza Mexico City ----- Original Message ----- From: "kj" <socyl at 987jk.com> To: mathgroup at smc.vnet.net Subject: [mg46983] [mg46946] How to get non-printing heads? > > How can I give a Mathematica object a different head? > > I tried > > In:= Head[a] ^= Constant; > > But, as shown below, this doesn't work as desired: > > In:= MatchQ[a, _Constant] > > Out= False > > In:= MatchQ[a, _Symbol] > > Out= True > > I even tried > > In:= a/: MatchQ[a, _Constant] = True; > > In:= ??a > Global`a > > Head[a] ^= Constant > > a /: MatchQ[a, _Constant] = True > > ...but > > In:= MatchQ[a, _Constant] > > Out= False > > Is there any way to give "a" a user-defined head? > > My immediate goal is to be able to define functions that perform > algebraic manipulations on Mathematica expressions according to > the types of the objects they contain. I want to leave these > objects pretty much undefined, other than specifying their types. > E.g.: > > myDerivative[x_Constant] := 0; > > myDerivative[a] > > ==> 0 > > myDerivative[b] > > ==> myDerivative[b] (* Derivative doesn't know how to handle Symbol *) > > TIA, > > kj > -- > NOTE: In my address everything before the period is backwards. > >