MathGroup Archive 2008

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

Search the Archive

Re: Operate on Heads

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,

On Mar 16, 6:49 am, "Dr Andy D Kucar P2EE4"
<a... at> 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

  • Prev by Date: Re: Bug: Derivative[] does not work with functions having slots in
  • Next by Date: Re: Speeding up FindMinimum setup
  • Previous by thread: Re: Operate on Heads
  • Next by thread: RE: Re: Operate on Heads