MathGroup Archive 2006

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

Search the Archive

Re: mapping of function revisited

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69950] Re: mapping of function revisited
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 28 Sep 2006 06:15:03 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <efdk8r$ri$1@smc.vnet.net>

Hi,

exp1 = x^3 + (1 + z)^2;

exp1 /. a : (x | z) :> Sin[a]

??

Regards

  Jens

<dimmechan at yahoo.com> schrieb im Newsbeitrag 
news:efdk8r$ri$1 at smc.vnet.net...
| Searching a little more I found one more 
alternative
|
| exp1 = x^3 + (1 + z)^2;
|
| MapAt[Sin, exp1, Flatten[(Position[exp1, #1] & ) 
/@ Cases[exp1, _?(
| !NumberQ[#1] & ), {-1}], 1]]
| Sin[x]^3 + (1 + Sin[z])^2
|
| Are there any other alternatives? Especially 
with proper pattern
| matching?
|
| Thinking a little harder I consider the 
following pure function
|
| g = TrueQ[First[ToCharacterCode[ToString[p]]] <
| First[ToCharacterCode[ToString[#1]]] <
| First[ToCharacterCode[ToString[z]]]] & ;
|
| Then
|
| MapAt[Sin, exp1, Flatten[(Position[exp1, #1] & ) 
/@ Cases[exp1, _?(
| !NumberQ[#1] && g[#1] & ), {-1}], 1]]
| (1 + z)^2 + Sin[x]^3
|
| Is it possible to obtain the previous result 
more compactly?
|
| Thanks
| 



  • Prev by Date: Re: Performance comparison Mac OSX vs. Windows XP
  • Next by Date: Re: Re: Re: why does not the Mathematica kernel seem to 'multi-task' between computations in different windows?
  • Previous by thread: Re: mapping of function revisited
  • Next by thread: strange random behavior ?