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

MathGroup Archive 2009

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

Search the Archive

Re: setting discrete values for a function -- newbie

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97643] Re: [mg97600] setting discrete values for a function -- newbie
  • From: "David Park" <djmpark at comcast.net>
  • Date: Tue, 17 Mar 2009 05:03:30 -0500 (EST)
  • References: <11718274.1237203325642.JavaMail.root@m02>

How about this method:

f[a] = 1; f[b] = 2; f[c] = 3;
{f[a], f[b], f[c]}
{1, 2, 3}

Do[f[i] = 0, {i, {a, b, c}}]
{f[a], f[b], f[c]}
{0, 0, 0}

David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  

From: Karsten W. [mailto:Karsten.G.Weinert at googlemail.com] 
Hello,

my task is to set some function values f[[a], f[b], ... to zero. Is
there a nicer way to do this than this one:

Clear[f];
args = Partition[{a,b,c}, 1];
Apply[(f[#] = 0 )&, args, {1}];

Especially, can I avoid calling Partition?


Best wishes,
Karsten.




  • Prev by Date: Re: importing fixed width data
  • Next by Date: Re: Don't understand the response
  • Previous by thread: Re: setting discrete values for a function -- newbie
  • Next by thread: Re: setting discrete values for a function -- newbie