Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: checking for a particular value in a matrix

  • To: mathgroup at
  • Subject: [mg31672] Re: checking for a particular value in a matrix
  • From: "Lawrence A. Walker Jr." <lwalker701_remove_ at>
  • Date: Fri, 23 Nov 2001 05:47:21 -0500 (EST)
  • Organization: Morgan State University, COMSARE
  • References: <9sb493$bn9$>
  • Sender: owner-wri-mathgroup at


Flatten[] removes all of the curly braces '{ }' inside a list.  Curly 
braces inside a list are said to demarcate objects that are at deeper 
levels in the list.  Objects at deeper levels in a list can be accessed 
by listname[[i,j,..]].  However, if flatten is used then all of the 
objects within the list are at the first level.  So listname[[i]] can be 
used to access any element within the list.

Hope this helps,

Au Han Bin wrote:

> does anyone understand what does Flatten does? the help file just tells me
> that it flattens. somehoww, it does not actually define what flatten does?
> regards, joshua_au at
> On Thu, 27 Sep 2001, David Park wrote:
>>This code will check that there is exactly one entry in a matrix of value 1.
>>ExactlyOneOne[(mat_)?MatrixQ] :=
>>  Count[mat, 1, Infinity] == 1
>>testmat1 = {{1, 0}, {2, 3}};
>>testmat2 = {{1, 0}, {2, 1}};
>>testmat3 = {{-1, 0}, {2, 3}};
>>ExactlyOneOne /@ {testmat1, testmat2, testmat3}
>>{True, False, False}
>>As for your second question, use a DelayedSet (:=). When you use Set (=)
>>Mathematica calculates the right hand side of the definition immediately -
>>even though the symbol a appears on the left hand side. This is a confusing
>>aspect of Mathematica definitions that trips up many users. I don't know why
>>Mathematica can't check to see if the symbol appears on the lhs. There is
>>probably some logic to it.
>>David Park
>>djmp at
>>>From: Au Han Bin [mailto:auhb3 at]
To: mathgroup at
>>>Hi, I am a programming newbie and I need advice on how to check that a
>>>table or matrix , for all nonzero entries in a given row, has only one
>>>entry of value 1.
>>>i have another query on why the code below does not work, when i call
>>>convert{1,0,0,0} again, the results given are from an earlier question,
>>>e.g. {1,1} is it initialised wrongly?
>>>convert[a___] = Sum[a[[i]]*2^(Length[a]-i),{i,1,Length[a]}]
>>>regards, thanks,

  • Prev by Date: Re: Evaluate Initialization button?
  • Next by Date: RE: Creating Objects
  • Previous by thread: Re: checking for a particular value in a matrix
  • Next by thread: Notebook question