MathGroup Archive 2007

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

Search the Archive

Re: "vector" Map[] / functional outer product?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83760] Re: "vector" Map[] / functional outer product?
  • From: "wyelen at gmail.com" <wyelen at gmail.com>
  • Date: Fri, 30 Nov 2007 05:12:08 -0500 (EST)
  • References: <fim8tq$rmd$1@smc.vnet.net>

On 11=D4=C229=C8=D5, =CF=C2=CE=E77=CA=B148=B7=D6, Mitch Murphy <mi... at lemma.=
ca> wrote:
> greetings,
>
> is there a simpler way to express
>
>         {f@#,g@#}& /@ {a,b,c}
>
>         -> {{f[a],g[a]},{f[b],g[b]},{f[c],g[c]}}
>
> ie. is there some mathematica function ??? such that
>
>         {f,g} ??? {a,b,c}
>
>         -> {{f[a],g[a]},{f[b],g[b]},{f[c],g[c]}}
>
> you might be asking what's so difficult about the "@#,@#,... & /@"  
> syntax, but what about when you don't have two functions f,g but 8-10  
> functions... the syntax gets ugly fast and hard to read.
>
> note that
>
>         Outer[{f, g}, {a, b, c}]
>
>         -> {{f, g}[a], {f, g}[b], {f, g}[c]}
>
> doesn't work, neither does
>
>         Outer[Apply, {f, g}, {a, b, c}]
>
>         ->{{a, b, c},{a, b, c}}
>
> thanks,
> Mitch

Hi Mitch,
is this what you are looking for?

In[1]:=
Transpose[ ( #1 /@ { x1, x2, x3 } &) /@ { func1, func2, func3 } ]
Out[1]=
{
  { func1[x1], func2[x1], func3[x1] },
  { func1[x2], func2[x2], func3[x2] },
  { func1[x3], func2[x3], func3[x3] }
}

hope this helps, wyelen


  • Prev by Date: Re: "vector" Map[] / functional outer product?
  • Next by Date: Re: Geocoding using Mathematica
  • Previous by thread: Re: "vector" Map[] / functional outer product?
  • Next by thread: Re: "vector" Map[] / functional outer product?