MathGroup Archive 2000

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

Search the Archive

Re: pure functions

  • To: mathgroup at
  • Subject: [mg23291] Re: [mg23237] pure functions
  • From: "Rosa Ma. Seco" <ceie at>
  • Date: Sun, 30 Apr 2000 21:13:41 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Helge Andersson wrote:

Of all the nice functions such as Map, Mapall, Thread, Apply .... I have
not been able to write a simple code to generate the following

I have a two dimensional list like


Since i like to use the pure function command I would like to map my
pure function with arguments #1,#2,#3,.... on all the sublists in li.

Let me exemplify with a simple pure function that add to numbers.

if exli={{1,2},{3,4},{5,6},{7,8}}

then I want to get the result

One solution, but not allways suitable for me, is the following

(#1+#2)&[Sequence @@ Transpose[exli]].

I want to get rid of the Transpose command and if possible also making
use of the /@ notation for Map. Since I have seen so many elegant
examples in the mailing lists I hope  I can get something out of this.

Finally, When using pure functions inside Mathematica defined functions
such as Select for instance,
why don't we need to specify the argument list after the &sign. I can
figure out that in this case the list sent to the Select command will be
used as argument list for the pure function but how does this work in
general. Which are the functions where this feature is possible?

--- Well, unless you specifically want to use pure functions in your
example, why not simply use Apply?



But if you want to force the use of a pure function in this case, write


which is just a different way of writing the same thing.

I think the following statement should answer your second question:
 "Select[list, f] selects elements of list using the function f as a
Select applies f to each element of list in turn, and keeps only those for
which the result is True"(Cf. The Book, 2.2.7).

Tomas Garza
Mexico City

  • Prev by Date: Re: pure functions
  • Next by Date: RE: pure functions
  • Previous by thread: Re: pure functions
  • Next by thread: RE: pure functions