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 |