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

MathGroup Archive 2011

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

Search the Archive

Re: Mapping to Create Nested Loops

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119430] Re: Mapping to Create Nested Loops
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Thu, 2 Jun 2011 19:12:42 -0400 (EDT)

Hi Szabolcs,

AFAIK, it is safe, as long as inner pure anonymous  function is totally
contained in the outer, being
passed as an argument. Here is one relevant mathgroup thread:

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/7688b58dbd9450b7

Regarding pure functions with named arguments, I try to avoid them because
the functional abstraction
is generally leaky in Mathematica. I pointed this out here:

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/115b073d95999ae8

and also discussed here:

http://stackoverflow.com/questions/4920194/using-nested-slots/4922776#4922776

You may also look at the bottom of this post:

http://stackoverflow.com/questions/4430998/mathematica-what-is-symbolic-programming/4435720#4435720

for a really short but instructive example illustrating the problem.

Cheers,
Leonid



2011/6/2 Szabolcs Horv=E1t <szhorvat at gmail.com>

> On 2011.06.01. 13:27, Bob Hanlon wrote:
> > GatherBy[myArray, #[[3]]&]
> >
> > GatherBy[#, #[[3]]&]&  /@ myListOfArrays
> >
> >
>
> Is this kind of use of nested functions with # guaranteed to be safe
> (let's disregard readability concerns for now)?
>
> It appears that # indeed is always the argument of the innermost
> function, but I couldn't find this stated in the docs.  Instead, it's
> suggested in the docs (page for Slot) to use named arguments with nested
> functions (but those aren't without name-conflict / localization issues
> either)
>
>


  • Prev by Date: Re: Portfolio Optimization
  • Next by Date: Re: Workbench - Recommendation?
  • Previous by thread: Re: Mapping to Create Nested Loops
  • Next by thread: Re: Mapping to Create Nested Loops