Re: Specifying arguments inside nested functions
- To: mathgroup at smc.vnet.net
- Subject: [mg46121] Re: [mg46107] Specifying arguments inside nested functions
- From: "Sseziwa Mukasa,,(978) 536-2359" <mukasa at jeol.com>
- Date: Sat, 7 Feb 2004 04:02:02 -0500 (EST)
- References: <200402060915.EAA19269@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Feb 6, 2004, at 4:15 AM, Ray Koopman wrote: > 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? Use the form of Function that allows named parameters eg. Select[A, Function[{r},And@@Map[Inner[Unequal,r,#,And]&,B]]] Regards, Ssezi
- References:
- Specifying arguments inside nested functions
- From: koopman@sfu.ca (Ray Koopman)
- Specifying arguments inside nested functions