MathGroup Archive 2009

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

Search the Archive

Re: Nesting functional commands

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102899] Re: [mg102875] Nesting functional commands
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 2 Sep 2009 03:59:36 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

While nesting of pure functions frequently fails due to an ambiguity, your example works fine on my system

$Version

7.0 for Mac OS X x86 (64-bit) (February 19, 2009)

A = {1, 2, 3, 4}

{1,2,3,4}

3 # & /@ A

{3,6,9,12}

Select[%, # < 7 &]

{3,6}

Select[3 # & /@ A, # < 7 &]

{3,6}


Bob Hanlon

---- Erin Noel <enoel2 at gmail.com> wrote: 

=============
Hi,

So how would you go about nesting a functional command inside of another
functional command? For example, say A={1,2,3,4}, then 3*#&/@A = {3,6,9,12}.
No problem. But then what if, within that vector {3,6,9,12}, I wanted to use
the Select command to choose elements less than, say 7. The command
Select[3*#&/@A,#<7&] doesn't work because, as far as I can tell, Mathematica
doesn't know which "#" belongs to Select and which "#" belongs to the &/@
mapping over A. I know that I could define 3*#&/@A as a new variable and
then use that new variable in the Select command, but is there any way to
nest multiple commands in this way?

Thanks a lot in advance,
Erin




  • Prev by Date: Re: Two Questions
  • Next by Date: Re: Two Questions
  • Previous by thread: Re: Nesting functional commands
  • Next by thread: Re: Nesting functional commands