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: [mg83773] Re: "vector" Map[] / functional outer product?
  • From: Mitch Murphy <mitch at lemma.ca>
  • Date: Fri, 30 Nov 2007 05:19:11 -0500 (EST)
  • References: <fim8tq$rmd$1@smc.vnet.net> <474ED0C0.9030008@gmail.com>

based on the solution from Jean-Marc Gulliet, here's a slight  
improvement based on overloading Map[] for List arguments. this solves  
my issue perfectly without having to type in esc sequences for infix  
operators

	Unprotect[Map];
	Map[f_List, a_List] := Transpose@Outer[Compose, f, a]
	Protect[Map];
	
	{f, g} /@ {a, b, c}

	-> {{f[a],g[a]},{f[b],g[b]},{f[c],g[c]}}


cheers,
Mitch



On Nov 29, 2007, at 09:46, Jean-Marc Gulliet wrote:

> 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



  • Prev by Date: Re: A problem with FindRoot
  • Next by Date: Re: "vector" Map[] / functional outer product?
  • Previous by thread: Re: "vector" Map[] / functional outer product?
  • Next by thread: Re: "vector" Map[] / functional outer product?