MathGroup Archive 2013

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

Search the Archive

MakeExpression on a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132141] MakeExpression on a list
  • From: Yi Wang <tririverwangyi at gmail.com>
  • Date: Tue, 24 Dec 2013 02:18:29 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Dear all, 

I was trying to use MakeExpression to translate 

Subscript[f, \[FilledSmallSquare]]

into 

f[x,y,z,t].

Currently, I can do it with

X={x,y,z,t}

MakeExpression[SubscriptBox[f_,"\[FilledSmallSquare]"],form_]
    := MakeExpression[RowBox[
        {f, "[",Sequence@@Riffle[Map[ToBoxes[#,form]&,X],","],"]"}],form]

However, I was wondering if there are simpler ways (using Riffle to make a sequence of strings seems stupid). Especially, why the following doesn't work:

MakeExpression[SubscriptBox[f_,"\[FilledSmallSquare]"],form_]
    := MakeExpression[f,form][x,y,z,t]

Thank you very much in advance!

Note:

I know I could use the Notation package, or directly write

MakeExpression[SubscriptBox[f_,"\[FilledSmallSquare]"],form_]
    := MakeExpression[RowBox[{f, "[x,y,z,t]"}],form]

However, I would like to be able to change coordinate, say X={x,y,z,t} into X={r, theta, phi, t} and use the same code to parse input. Thus I don't want to hard code "[x,y,z,t]". Also the Notation package doesn't seem to provide such flexibility. 

Merry Christmas and happy new year!
Yi



  • Prev by Date: Why are only the cuboids near the surfaces visible?
  • Next by Date: Re: Mathworld Utility Packages
  • Previous by thread: Why are only the cuboids near the surfaces visible?
  • Next by thread: Re: MakeExpression on a list