Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2916

Re: Mapping to Create Nested Loops

From Leonid Shifrin <lshifr@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Mapping to Create Nested Loops
Date 2011-06-02 23:12 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <is95d2$62b$1@smc.vnet.net> (permalink)

Show all headers | View raw


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@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)
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Mapping to Create Nested Loops Leonid Shifrin <lshifr@gmail.com> - 2011-06-02 23:12 +0000

csiph-web