The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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


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?



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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.