Mathematica 9 is now available
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


You can use an alternative form for anonymous functions:

Function[{params},body]

to name the parameters which will allow disambiguation eg:

Select[{1,2,3},Function[{outer},f[outer,#]&/@{-1,-2,3}=={3,4,5}]]

or

Select[{1,2,3},Function[{outer},Function[{inner},f[outer,inner]]/@{-1,-2,3}=={3,4,5}]]

On Apr 27, 2012, at 6:48 AM, Dave Snead 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: Re: Instability with Dynamic content
  • Next by Date: Transcendental functions
  • Previous by thread: Distinquishing #'s in nested pure functions
  • Next by thread: Re: Distinquishing #'s in nested pure functions