Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Specifying arguments inside nested functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46107] Specifying arguments inside nested functions
  • From: koopman at sfu.ca (Ray Koopman)
  • Date: Fri, 6 Feb 2004 04:15:32 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I have two matrices, A and B, that have the same number of columns.
I want to select the rows of A that differ in every position from
every row of B. So I write

   Select[A, And@@Map[Inner[Unequal,#1,#2,And]&, B]& ]

But that won't work, because I have no way to tell Inner that one of
its arguments should be the row of A that is being tested by Select,
and the other argument should be the row of B from Map.

Now, I realize that there are ways around the problem in this
particular case. For instance, the Select test could be

   And@@Map[FreeQ[Rest[#],First[#]]&, Transpose@Prepend[B,#]]&

which checks B a column at a time and might well be more efficient.
However, this is not the first time I've run into the problem of
specifying arguments inside nested functions, and I wonder how other
people handle it. Is there a general solution, or must I always
ad hoc it?


  • Prev by Date: Re: how to test if 2 expressions are the same? Mathematica 5.0
  • Next by Date: Re: Simple Differentiation?
  • Previous by thread: Re: Re: Find last NZ in list
  • Next by thread: Re: Specifying arguments inside nested functions