Re: Operate on Heads
- To: mathgroup at smc.vnet.net
- Subject: [mg86661] Re: Operate on Heads
- From: Januk <ggroup at sarj.ca>
- Date: Mon, 17 Mar 2008 00:21:13 -0500 (EST)
- References: <friu0f$jo$1@smc.vnet.net>
Hi Andy, A basic approach would be to convert everything to strings, use Mathematica's string manipulation commands to create the expression you'd like evaluated, then convert back to an expression. See below for a simple example. f[something_, x__] := Module[{strArgs, strHeads}, strHeads = ToString[something]; strArgs = Riffle[ToString /@ {x}, ","]; (* Manipulate your heads here *) strHeads = StringReplace[strHeads, "p" -> "P"]; StringJoin[strHeads, "[", strArgs, "]" ] // ToExpression ] f[plus, 2, 3] Hope that helps, Januk On Mar 16, 6:49 am, "Dr Andy D Kucar P2EE4 www.radio4u.com" <a... at radio4u.com> wrote: > Hi, > > Hi, > > I would like to be able to pass a composite name Head, e.g., > FirstSecondThird to a Module, > and then, inside the module, use > > FirstSecondThird, First, Second, Third > > Heads, and/or make other Operate ions on Heads > > How could this be accomplished? > Thank you > > Sincerely Andy