Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Pure function in a pure function (again)
Replies: 3   Last Post: Sep 23, 2006 11:55 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Skirmantas Janusonis

Posts: 6
From: University of California, Santa Barbara
Registered: 9/15/06
Pure function in a pure function (again)
Posted: Sep 23, 2006 5:09 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.