Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Format

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111555] Format
  • From: Derivator <salcedo at ugr.es>
  • Date: Thu, 5 Aug 2010 06:59:19 -0400 (EDT)

Hi. I need some help. The commands

Format[a[x_]]:=f[x,a];
Format[a[x_,c]]:=a[x];
Format[b[x_]]:=f[x,b];
Format[b[x_,c]]:=b[x];

assign a certain format to the symbols a and b, so that the input

{a[1],a[2,c],b[3],b[4,c]}

yields

{f[1,a],f[2,a],f[3,b],f[4,b]}

Now I want to do the same thing for several symbols a,b,.... all at
once.
I have tried

list={a,b};
Do[
Format[z[x_]]:=f[x,z];
Format[z[x_,c]]:=z[x];
,{z,list}];

but it does not work. The input

{a[1],a[2,c],b[3],b[4,c]}

yields

{f[1,z],z[2],f[3,z],z[4]}

Likewise the following also fails:

list={a,b};
Format[z_[x_]]:=f[x,z]/;MemberQ[list,z];
Format[z[x_,c]]:=z[x]/;MemberQ[list,z];

Any suggestions?
Thanks in advance

L.L.


  • Prev by Date: Re: Deleting entries with zero in a table
  • Next by Date: how to work with custom probability distributions
  • Previous by thread: discussions on the language: For and Which
  • Next by thread: Re: Format