Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Distinquishing #'s in nested pure functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126278] Re: Distinquishing #'s in nested pure functions
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Sat, 28 Apr 2012 05:27:53 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201204260933.FAA05752@smc.vnet.net> <jndtj1$jit$1@smc.vnet.net>

For situations like this I always use explicit calls to Function[...],
though for the innermost our function I may use the shorthand #, &
form.   In addition to avoiding potential ambiguities, it makes the
code readable.

--David


On Apr 27, 6:49 am, "Dave Snead" <dsne... at charter.net> wrote:
> Hi,
>
> Is there a way to distinguish the #'s in nested pure functions?
>
> As a simple example:
>
> f[x_, y_] := x - y
>
> Select[{1, 2, 3}, (f[#, #] & /@ {-1, -2, -3}) == {3, 4, 5} &]
>
> I want the 1st # to correspond with the outer & (the equal)
> and the 2nd # with the inner & (the map)
> The answer in this example should by {2}
> (of course, the statement as written above does not do the job)
>
> Can Mathematica distinguish these #'s?
>
> Thanks in advance,
> Dave Snead




  • Prev by Date: Question about Integration and citation
  • Next by Date: Re: Distinquishing #'s in nested pure functions
  • Previous by thread: Re: Distinquishing #'s in nested pure functions
  • Next by thread: Re: Distinquishing #'s in nested pure functions