Re: "vector" Map[] / functional outer product?
- To: mathgroup at smc.vnet.net
- Subject: [mg83762] Re: "vector" Map[] / functional outer product?
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 30 Nov 2007 05:13:14 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <fim8tq$rmd$1@smc.vnet.net>
Mitch Murphy 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]}}
<snip>
The following expression (In[1]) will return the desired list without
the burden of passing explicitly any arguments to your functions.
In[1]:= Outer[Compose, {f, g}, {a, b, c}] // Transpose
Out[1]= {{f[a], g[a]}, {f[b], g[b]}, {f[c], g[c]}}
Note that if you want a nice infix notation, you could add some meaning
to a symbol without any built-in meaning, such as CirclePlus (On the
keyboard, you can enter the symbol CirclePlus as Esc c+ Esc --- i.e.
escape key followed by c followed by + followed by the escape key.)
In[2]:= CirclePlus[f_, a_] := Transpose[Outer[Compose, f, a]]
In[3]:= {f, g}\[CirclePlus]{a, b, c}
Out[3]= {{f[a], g[a]}, {f[b], g[b]}, {f[c], g[c]}}
Regards,
--
Jean-Marc