Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2011

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

Search the Archive

Re: Matrices as operators

  • To: mathgroup at
  • Subject: [mg123216] Re: Matrices as operators
  • From: Chris Young <cy56 at>
  • Date: Sun, 27 Nov 2011 04:12:29 -0500 (EST)
  • Delivered-to:
  • References: <jaal4e$12d$> <jafu4b$ro7$> <janol1$aqb$> <jaqe26$nhv$>

Checking out the Help for Map, I found that you could put tests in with 
an If[ ] that was acting as a pure function.  I think the following 
will always do what I want. Should be much faster than using While 
loops, too.

op2[arr_, t_] :=
 If[! (NumericQ[#] || StringQ[#]),
  ] &,

In[38]:= op2[{{Sin, 3 E, Cos}, Tan, {Cos, Cos[Cos], 1}, "string"}, t]

Out[38]= {{Sin[t], 3 E, Cos[t]}, Tan[t], {Cos[t], Cos[Cos[t]], 1}, "string"}

The {-1} tells Map to only apply the change to the ends of the 
expression tree. The If[ ] filters out numbers and strings, which are 
not valid function names.

Some more tests would have to be added if you wanted this to work for 
indexed functions such as f[k][x].

Seems like this is probably the fastest way to accomplish what I want, 
since it's all built-in. Amazing!

Chris Young
cy56 at

  • Prev by Date: Re: Texture on Disk in Mathematica 8?
  • Next by Date: Re: Domain of a function
  • Previous by thread: Re: Matrices as operators
  • Next by thread: Re: Matrices as operators