Hi all, I would like to reverse the elements of an array (or vector). If it were a regular Python list, I could say L.reverse(). If it were in Matlab (ick), I could say U(4:-1:1). Can anyone give me a hint on doing this in Numeric (not Numarray)? Thx
A Monday 18 July 2005 20:00, Egg va escriure:
I would like to reverse the elements of an array (or vector). If it were a regular Python list, I could say L.reverse(). If it were in Matlab (ick), I could say U(4:-1:1). Can anyone give me a hint on doing this in Numeric (not Numarray)?
import Numeric a=Numeric.arange(10) a[::-1] array([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])
(the same works for python lists) Cheers, --
0,0< Francesc Altet http://www.carabos.com/ V V Cárabos Coop. V. Enjoy Data "-"
Egg wrote:
Hi all,
I would like to reverse the elements of an array (or vector). If it were a regular Python list, I could say L.reverse(). If it were in Matlab (ick), I could say U(4:-1:1). Can anyone give me a hint on doing this in Numeric (not Numarray)?
In [2]: U = arange(10) In [3]: U[::-1] Out[3]: array([9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
participants (3)
-
Egg
-
Francesc Altet
-
Robert Kern