MathGroup Archive 2012

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

Search the Archive

Re: take square of the second and third column of a table

Try this:

lst = RandomInteger[{0, 5}, {7, 3}] (* this is a list like yours *)

lst // MatrixForm


  Transpose[lst] /. {x_, y_, z_} -> {x, y^2, z^2}] // MatrixForm

Or this:

g[{x_, y_, z_}] := {x, y^2, z^2};

Map[g, lst] // MatrixForm

Have fun.

Hello, suppose I have a very long table like this:

1 2 3

4 5 6

7 8 9


2 3 4

how can I take square of the 2nd and 3rd column? I always do it by

making a new table. so let's say the above table is A and it has 100

lines, then I make the new table as the following:


But if the length of the table is unknown, this way is impractical.

Could anyone suggests better way? thank you

Alexei BOULBITCH, Dr., habil.


ZAE Weiergewan,

11, rue Edmond Reuter,

L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566

Office fax:       +352-2454-3566

mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at<mailto:alexei.boulbitch at>

  • Prev by Date: KeyEventTranslations: how to make them work with *two* modifiers? (Both Shift and Control)
  • Next by Date: Solve stuck at 243
  • Previous by thread: Re: take square of the second and third column of a table
  • Next by thread: Minimize: new method vs old method