MathGroup Archive 2006

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

Search the Archive

Re: Using Map with function that has options...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68499] Re: Using Map with function that has options...
  • From: Peter Pein <petsie at dordos.net>
  • Date: Tue, 8 Aug 2006 06:28:34 -0400 (EDT)
  • References: <eb6k2b$nkt$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Giacomo Ciani schrieb:
> I have several expressions I whant to convert to string and then
> concatenate togheter to create a message to be sent to the standard
> output and written on a text log file. To avoid manually appliyng
> ToString to each of them, I'm using something like:
> 
> myMessage = StringJoin@@Map[ToString,{expr1,expr2,expr3,...,exprN}]
> 
> The problem is that I would like to specify the option
> "TraditionalForm" for ToString (without that, the exponents are written
> on a different line compromising the formatting), but I can't
> understand if using this tecnique I can do that, and how.
> 
> Obviously I can solve the problem with an explicit loop over the
> element of the array, but I was looking for a more elegant solution...
> any idea?
> 
> Thanks
> 
> Giacomo
> 
> P.S. expr are in general both strings or numeric values
> 

Hi Giacomo,

  if you specify FormatType->TraditionalForm (or StandardForm), you get all these "\(", "\!" etc. in the resulting string.

It doesn't look as nice as TraditionalForm, but InputForm gives you a simple string:

In[1]:=
StringJoin@@
   Map[ToString[#,FormatType\[Rule]InputForm]&,{x^2,BesselJ[0,z^4/2]}]
Out[1]=
x^2BesselJ[0, z^4/2]
In[2]:=
%//FullForm
Out[2]//FullForm=
"x^2BesselJ[0, z^4/2]"

hth
   Peter


  • Prev by Date: Re: Using Map with function that has options...
  • Next by Date: Newbie question about column sums of arrays
  • Previous by thread: Re: Using Map with function that has options...
  • Next by thread: Re: Using Map with function that has options...