Re: Re: buliding on functions
- To: mathgroup at smc.vnet.net
- Subject: [mg79131] Re: [mg79104] Re: buliding on functions
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Thu, 19 Jul 2007 03:34:07 -0400 (EDT)
- References: <31175889.1184782798320.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
Here are a couple more options:
functions = {f1, f2, f3};
data = {{1, 2, 3, 4}, {5, 6, 7}};
Outer[#1[#2] &, functions, data]
{{{f1[1], f1[2], f1[3], f1[4]}, {f1[5], f1[6], f1[7]}}, {{f2[1],
f2[2], f2[3], f2[4]}, {f2[5], f2[6], f2[7]}}, {{f3[1], f3[2],
f3[3], f3[4]}, {f3[5], f3[6], f3[7]}}}
Distribute[map[functions, data], List] /. map -> Map
{{f1[1], f1[2], f1[3], f1[4]}, {f1[5], f1[6], f1[7]}, {f2[1], f2[2],
f2[3], f2[4]}, {f2[5], f2[6], f2[7]}, {f3[1], f3[2], f3[3],
f3[4]}, {f3[5], f3[6], f3[7]}}
Flatten to taste.
Bobby
On Wed, 18 Jul 2007 02:06:12 -0500, chuck009 <dmilioto at comcast.com> wrote:
> This is an example of a set of three functions operating on a nested
> list. I'm just using the shortcut for Map by mapping the list of
> functions onto the nested list of data:
>
> In[34]:=
> f1[x_]:=Sin[x];
> f2[x_]:=Cos[x];
> f3[x_]:=x^2;
>
> Flatten[{f1[#],f2[#],f3[#]}& /@ {{1,2,3,4},{5,6,7}}]
>
> Out[37]=
> {Sin[1],Sin[2],Sin[3],Sin[4],Cos[1],Cos[2],Cos[3],Cos[4],1,4,9,16,
> Sin[5],Sin[6],Sin[7],Cos[5],Cos[6],Cos[7],25,36,49}
>
>
>> so i have a group functions that i want to work on
>> three list at the
>> same time. everytime i've tryed to get mathematica to
>> run through all
>> at the smae time. i find out the functions only acted
>> on one list. any
>> ideas?
>>
>>
>
>
-- =
DrMajorBob at bigfoot.com