Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

How to get non-printing heads?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46946] How to get non-printing heads?
  • From: kj <socyl at 987jk.com>
  • Date: Tue, 16 Mar 2004 19:55:13 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

How can I give a Mathematica object a different head?

I tried

  In[1]:= Head[a] ^= Constant;

But, as shown below, this doesn't work as desired:

  In[2]:= MatchQ[a, _Constant]

  Out[2]= False

  In[3]:= MatchQ[a, _Symbol]

  Out[3]= True

I even tried

  In[4]:= a/: MatchQ[a, _Constant] = True;

  In[5]:= ??a
  Global`a

  Head[a] ^= Constant
   
  a /: MatchQ[a, _Constant] = True

...but

  In[6]:= MatchQ[a, _Constant]

  Out[6]= 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.


  • Prev by Date: RE: How to read a string from a file?
  • Next by Date: Left/right justifying rotated text
  • Previous by thread: Re: List of Variables and manipulating them ...
  • Next by thread: Re: How to get non-printing heads?