Re: RandomList and pure function

• To: mathgroup at smc.vnet.net
• Subject: [mg70858] Re: [mg70833] RandomList and pure function
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Mon, 30 Oct 2006 05:32:18 -0500 (EST)

```lis=Array[a,{4,2}];

Your function's argument (a row) is a single list of length 2.

ans=(#[[1]]+2 #[[2]])&/@lis

{a[1, 1] + 2*a[1, 2], a[2, 1] + 2*a[2, 2], a[3, 1] + 2*a[3, 2],
a[4, 1] + 2*a[4, 2]}

Alternatively, this can be written

ans==({1,2}.#&)/@lis

True

Bob Hanlon

---- Marc VIAL <marcvial at msn.com> 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.
>
>
> Thanks
> Marc
> _________________________________________________________________
>
>

--

Bob Hanlon
hanlonr at cox.net

```

• Prev by Date: Curiosity concerning transformation rules for List
• Next by Date: FindRoot, suppressing complex interval-numbers
• Previous by thread: Re: RandomList and pure function
• Next by thread: Re: RandomList and pure function