Re: Re: Mapping a pure function with 2 conponents.
- To: mathgroup at smc.vnet.net
- Subject: [mg77377] Re: [mg77321] Re: Mapping a pure function with 2 conponents.
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Thu, 7 Jun 2007 04:01:59 -0400 (EDT)
- References: <f43i20$3hl$1@smc.vnet.net> <24080548.1181133969665.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
Much simpler is: #1^2 + #2 & @@@ {{0, 1}, {2, 3}, {4, 5}} {1, 7, 21} Bobby On Wed, 06 Jun 2007 06:33:09 -0500, Adriano Pascoletti <adriano.pascoletti at gmail.com> wrote: > On Jun 5, 1:39 pm, phoenix7... at gmail.com wrote: >> I'm trying to get the following code to work: >> >> Map[#1^2 + #2 &, {{0, 1}, {2, 3}, {4, 5}}] >> >> The goal is to use a pure function in order to achieve the result: >> {1, 7, 21} >> >> The issue is that the evaluation involves #1^2 + #2 & [{0,1}] >> instead of #1^2 + #2 & [0,1] >> >> Thanks, in advance. > > You must access the first and the second part of the (unique) argument > (#1) > In[1]:= (#1[[1]]^2 + #1[[2]] & ) /@ {{0, 1}, {2, 3}, {4, 5}} > > Out[1]= {1, 7, 21} > > Adriano Pascoletti > > > -- DrMajorBob at bigfoot.com