       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>

```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.

> 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

```

• Prev by Date: Re: collecting certain powers
• Next by Date: writing a function that would print the name of a passed variable
• Previous by thread: setting discrete values for a function -- newbie
• Next by thread: Re: setting discrete values for a function -- newbie