MathGroup Archive 2006

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

Search the Archive

Re: a[[0]] equivalent to a[[-1]] and so forth


Hi Alexandra,
Mod with offset will do what you want:

a[[ Mod[index,3,1] ]]

Daniel

Alexandre Costa wrote:
> Dear Group,
> I have a simple issue:
> If  I have a list such as :
> a = {4, 5, 6};
> How can I do this in an elegant way:
> a[[0]] equivalent to a[[-1]]
> a[[-1]] equivalent to a[[-2]]
> and so forth.
> 
> I thought of a[[If[i <=0, i - 1, i]]] would solve the problem
> but I want a more elegant way of doing this.
> 
> Any help is very welcome,
> Thanks,
> Alex
> 
> 


  • Prev by Date: How to get rid of If[ ... ] in a result
  • Next by Date: getting one random number
  • Previous by thread: a[[0]] equivalent to a[[-1]] and so forth
  • Next by thread: Re: a[[0]] equivalent to a[[-1]] and so forth