Re: List of function-heads
- To: mathgroup at smc.vnet.net
- Subject: [mg17141] Re: List of function-heads
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 17 Apr 1999 03:35:25 -0400
- References: <7f1g3u$ku0@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Peter,
Here are some ideas.
Clear["`*"]
fl = Table[a[i], {i, 2}]
{a[1], a[2]}
(Unevaluated[Set[fl, #]] /. OwnValues[fl]) &[{1, 2}];
?a
"Global`a"
a[1] = 5
a[2] = 6
With[{ov = OwnValues[fl], nv = {3, 4}},
Unevaluated[Set[fl, nv]] /. ov];
?a
"Global`a"
a[1] = 5
a[2] = 6
ReleaseHold[Block[{a}, Hold[Set[##]] &[fl, {5, 6}]]];
?a
"Global`a"
a[1] = 5
a[2] = 6
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
Peter Breitfeld <phbrf at t-online.de> wrote in message
news:7f1g3u$ku0 at smc.vnet.net...
> I want to create a List of function-heads like this:
> {a[1][x_],a[2][x_],...,a[n][x_]}
> (to keep this message short I'll use n=2 in the following) to assign
> these to a list of Functions, e.g
>
> {a[1][x_],a[2][x_]}={x^2,x-1}
>
> I can do that with the following command:
>
> In[1]:=fl=Table[a[i][x_],{i,2}]
> Out[1]={{a[1][x_],a[2][x_]}
>
> But then I can't write:
>
> ll={x^2,x-1}
>
> because now the a[i] are overwritten and not assosiated with the
> elements of the rhs.
>
> Is there a way to get it working? I tried Thread, MapThread and some
> more but didn't find a solution.
>
> TIA
>
> Es gruesst Peter
> --
> =--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
> Peter Breitfeld, Saulgau, Germany PGP public key: 08548045
>