comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Swap even/odd elements in array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Swap even/odd elements in array [message #44502] Wed, 22 June 2005 02:20
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
This is yet another possibility...

a=['a0','a1','a2','a3','a4','a5']

n=n_elements(a)
b=lindgen(n+1)
c=b+2*(b mod 2)-2

ashifted=a[c[1:n]]
print,a,ashifted

Paolo

photosalex@freenetname.co.uk wrote:
> Hi All,
> sorry if the question is trivial:
> how could I swap even and odd elements of a 1-D 16-bit INT array
> without using loops? That is, if the source array is
>
> [a0,a1,a2,a3,..]
>
> I want it to be
>
> [a1,a0,a3,a2,..]
>
> Thanks!
>
[Message index]
 
Read Message
Previous Topic: Re: converting bytarr into strarr
Next Topic: Re: Color in PLOT(S)??

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:02:40 PDT 2025

Total time taken to generate the page: 0.43235 seconds