Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Problem with Position applied on 2D list?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72622] Re: Problem with Position applied on 2D list?
  • From: dh <dh at metrohm.ch>
  • Date: Fri, 12 Jan 2007 06:13:51 -0500 (EST)
  • References: <eo4n23$l4i$1@smc.vnet.net>


Hi Heiko,

the problem with your code is that "_" matches everything ( e.g. the 

head). This works if the match part must contain 5 e.g.the head does not 

contain 5). But it fails badly otherwise. Therefore, you must be more 

specific, e.g. instead of "_" the more specific: "{_Integer ..}".

Daniel



Heiko Damerau wrote:

> Dear All,

> 

>      There is some strange behaviour of the Position[] function I am 

> struggling with:

> 

> integerRandomTable = Table[Table[Random[Integer, 10], {10}], {10}];

> 

> Find the position of all lists containing the value 5 (just a simple 

> example):

> 

> Position[integerRandomTable, _?(MemberQ[#, 5] &)]

> 

> gives the expected result, e.g. {{1}, {3}, {4}, {5}, {6}, {7}, {8}}.

> However, just asking for all lists not containing the value 5

> 

> Position[integerRandomTable, _?(Not[MemberQ[#, 5]] &)]

> 

> Doesn't give the expected result but some strange thing, e.g. {{0}, 

> {1,0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, ..., {10, 3}, {10, 4}, {10, 5}, 

> {10, 6}, {10, 7}, {10, 8}, {10, 9}, {10, 10}, {10}, {}}

> 

>      What is the explanation for the different behaviour of MemberQ[] 

> and Not[MemberQ[]]?

> 

>      Thanks a lot in advance for any help.

> 

> Best regards,

> Heiko

> 



  • Prev by Date: Re: sparsearray and its nonempty cells
  • Next by Date: Re: Mathematica newbie
  • Previous by thread: Re: Problem with Position applied on 2D list?
  • Next by thread: mathematica on linux