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

Pure function in a pure function (again)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69797] Pure function in a pure function (again)
  • From: Skirmantas Janusonis <janusonis at psych.ucsb.edu>
  • Date: Sat, 23 Sep 2006 04:44:56 -0400 (EDT)

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?

Thanks!

Skirmantas


  • Prev by Date: Workbench does weird things with the In variable
  • Next by Date: Re: Suggestions for translating a Do[] loop ...
  • Previous by thread: Workbench does weird things with the In variable
  • Next by thread: Re: Pure function in a pure function (again)