[Numpy-discussion] Reversing elements of array

Robert Kern rkern at ucsd.edu
Mon Jul 18 11:50:26 CDT 2005


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 at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Numpy-discussion mailing list