Re: RandomList and pure function
- To: mathgroup at smc.vnet.net
- Subject: [mg70883] Re: RandomList and pure function
- From: "Philipp" <Philipp.M.O at gmail.com>
- Date: Mon, 30 Oct 2006 05:33:23 -0500 (EST)
- References: <ei18or$8n7$1@smc.vnet.net>
Marc,
The soluton is:
Apply[(#1 + 2 #2) &, lis, {1}]
or for the "shorthanded" purist
(#1 + 2 #2) & @@@ lis
A good way to see how various "mapping" functions work is to wrap the
formal arguments of pure function with symbols, in your case
Clear[h, g];
Map[(h[#1] + 2 g[#2]) &, lis, {1}]
Apply[(h[#1] + 2 g[#2]) &, lis, {1}]
Cheers,
Philipp
Marc VIAL wrote:
> Hi,
>
> Sorry for this naive question, but I try to apply a pure function of 2 arguments to a list of n rows with 2 clm using the mapping function:
>
> n=100;lis=RandomReal[{0,1},{n,2}];
> (#1+2 #2)&/@lis
>
> however it only captures the first term in the list and leave #2 unassigned.
>
> Any advice?
>
> Thanks
> Marc
> _________________________________________________________________