Re: a[[0]] equivalent to a[[-1]] and so forth
- To: mathgroup at smc.vnet.net
- Subject: [mg65153] Re: a[[0]] equivalent to a[[-1]] and so forth
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Wed, 15 Mar 2006 23:59:27 -0500 (EST)
- Organization: Uni Leipzig
- References: <dv8v5k$n91$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, lst = {4, 5, 6}; Table[lst[[Mod[i, Length[lst]] + 1]], {i, -6, 6}] ?? Regards Jens "Alexandre Costa" <amscosta at uem.br> schrieb im Newsbeitrag news:dv8v5k$n91$1 at smc.vnet.net... | 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 | |