Re: Handling a list: Could you find a more elegant solution?
- To: mathgroup at smc.vnet.net
- Subject: [mg38291] Re: [mg38195] Handling a list: Could you find a more elegant solution?
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Tue, 10 Dec 2002 04:19:00 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
It seems to me that at least for shortness this will be hard to beat: (list1 + RotateLeft[list1])/2 {(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2, (a + e)/2} Andrzej Kozlowski Yokohama, Japan http://www.mimuw.edu.pl/~akoz/ http://platon.c.u-tokyo.ac.jp/andrzej/ On Thursday, December 5, 2002, at 05:29 PM, guillerm at usal.es wrote: > I have a list: > > list1 = {a, b, c, d, e}; > > I want manipulate the list to obtain: > > (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*) > > It can be done for this function > > f[data_List] := Drop[Plus @@ NestList[RotateRight, data, > 1], 1]/2 > > f[list1] > > but I am sure that some member of the group can find a more elegant > function. I > will appreciate to know it. > > Thanks > > Guillermo Sanchez > > > --------------------------------------------- > This message was sent using Endymion MailMan. > http://www.endymion.com/products/mailman/ > > > > >