Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pure function in a pure function (again)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69823] Re: [mg69797] Pure function in a pure function (again)
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Sat, 23 Sep 2006 23:45:32 -0400 (EDT)
  • References: <200609230844.EAA22562@smc.vnet.net>

On Sep 23, 2006, at 4:44 AM, Skirmantas Janusonis wrote:

> Hello,
>
> I've already asked this question, but I thought there was a better way 
> to state it. If Dat is a 2D-table, the following picks out the rows 
> whose first element is 1,2 or 3 and adds up their the second elements:
>
> f[x_] := Plus @@ Column[Select[Dat, #[[1]] == x &], 2]
> f /@ Range[3]
>
> Instead of f/@Range[3], I'd like to use a second pure function, 
> something like this:
>
> Map[Plus @@ Column[Select[Dat, #1[[1]] == #2 &], 2]&,Range[3]]
>
> This line is incorrect, however. How do I fix it?

Map[Function[x,Plus@@Column[Select[Dat,#1[[1]]==x&],2]],Range[3]]

Regards,

Ssezi


  • Prev by Date: Re: Differentiation problem/bug?
  • Next by Date: Re: trivial question
  • Previous by thread: Pure function in a pure function (again)
  • Next by thread: Re: Pure function in a pure function (again)