Re: a[[0]] equivalent to a[[-1]] and so forth
- To: mathgroup at smc.vnet.net
- Subject: [mg65148] Re: a[[0]] equivalent to a[[-1]] and so forth
- From: dh <dh at metrohm.ch>
- Date: Wed, 15 Mar 2006 23:59:23 -0500 (EST)
- References: <dv8v5k$n91$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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
>
>