MathGroup Archive 2006

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

Search the Archive

Re: Lists and rules

  • To: mathgroup at
  • Subject: [mg66510] Re: Lists and rules
  • From: Bill Rowe <readnewsciv at>
  • Date: Wed, 17 May 2006 03:30:18 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 5/15/06 at 11:49 PM, thomas.??? at (Thomas
Schmelzer) wrote:

>Experts, I would like to produce a decent piece of code for one of
>my projects. I am constructing a list of sets

>S_1, S_2 and S_3

>where S_j = { m  ,   T[[1,m]] == j, m running from 1 to 100}

>T[[1,*]] is a row vector containing only 1, 2 and 3.

>I could setup a for loop and work with append. I have done that, but
>I believe this approach is neither efficient nor elegant. Any hints
>for a newbie?

Table will do what you want. That is

Table[{m, T[[1,m]]==j},{j,3},{m,100}]

will return a list containing all three lists. Note, I have assumed when you wrote T[[1,m]]==j you have correctly shown what you want to do.  If T[[1,j]] actually does return a row vector then T[[1,m]]==j will always be False since j is an integer. In this case the code I wrote will return exactly the same as:


which doesn't seem very useful.
To reply via email subtract one hundred and four

  • Prev by Date: Re: Reconstructing data points from a InterpolatingFunction object
  • Next by Date: Re: Fancy pictures in 3D
  • Previous by thread: Re: Lists and rules
  • Next by thread: Re: Lists and rules