Re: setting discrete values for a function -- newbie
- To: mathgroup at smc.vnet.net
- Subject: [mg97628] Re: [mg97600] setting discrete values for a function -- newbie
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Tue, 17 Mar 2009 05:00:38 -0500 (EST)
- References: <200903161128.GAA27240@smc.vnet.net>
- Reply-to: drmajorbob at bigfoot.com
To review, here's your code: Clear[f]; args=Partition[{a,b,c},1] {{a},{b},{c}} Apply[(f[#]=0)&,args,{1}] {0,0,0} ?f Global`f f[a]=0 f[b]=0 f[c]=0 The Partition instance could be replaced with: List /@ {a, b, c} {{a}, {b}, {c}} But that's not needed, and the definition of f could be Clear[f] (f[#]=0)&/@{a,b,c} {0,0,0} ?f Global`f f[a]=0 f[b]=0 f[c]=0 Bobby On Mon, 16 Mar 2009 06:28:08 -0500, Karsten W. <Karsten.G.Weinert at googlemail.com> wrote: > 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. > -- DrMajorBob at bigfoot.com
- References:
- setting discrete values for a function -- newbie
- From: "Karsten W." <Karsten.G.Weinert@googlemail.com>
- setting discrete values for a function -- newbie