MathGroup Archive 2009

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

Search the Archive

Re: Manipulating list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101508] Re: Manipulating list
  • From: Malcolm <mwjdavidson at googlemail.com>
  • Date: Thu, 9 Jul 2009 01:54:28 -0400 (EDT)
  • References: <h31utf$c2a$1@smc.vnet.net>

On Jul 8, 1:11 pm, kosal lee <leeko... at yahoo.com> wrote:
> Hello Mathematica users
>
> I am new to Mathematica and I have one particular problem I would like yo=
u to help me.
> Suppose I have two lists:
>
>     list1 = {{A,B,C},{D,E,F},{G,H,I}}
>     list2 = {{1,2},{3,4},{5,6}}
>
> I want to have the third elements in each of member list in list1 (that i=
s, C,F,I) to appear in the first position in each member list in list2
>
> that is, i want to have  list ={{C,1,2},{F,3,4},{I,5,6}}
>
>  Thank you.
> Kosal

Here is one solution (I've changed to lower case as some capital case
letters are variables in Mathematica e.g. I for imaginary part)

list1 = {{a, b, c}, {d, e, f}, {e, h, i}};
list2 = {{1, 2}, {3, 4}, {5, 6}};
Flatten /@ Thread@List[list1[[All, 3]], list2[[All, 1 ;; 2]]]

Mac



  • Prev by Date: Re: Selecting Rows Based on Column Values
  • Next by Date: Re: matrix equation
  • Previous by thread: Re: Manipulating list
  • Next by thread: Re: Manipulating list