RE: Handling a list: Could you find a more elegant solution?
- To: mathgroup at smc.vnet.net
- Subject: [mg38247] RE: [mg38195] Handling a list: Could you find a more elegant solution?
- From: "Harvey P. Dale" <h.dale at atlanticphilanthropies.org>
- Date: Tue, 10 Dec 2002 04:09:54 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Guillermo: Perhaps this -- #/2 & /@ Plus @@@ Partition[{a, b, c, d, e}, 2, 1] Best, Harvey Harvey P. Dale University Professor of Philanthropy and the Law Director, National Center on Philanthropy and the Law New York University School of Law Room 206A 110 West 3rd Street New York, N.Y. 10012-1074 tel: 212-998-6161 fax: 212-995-3149 -----Original Message----- From: guillerm at usal.es [mailto:guillerm at usal.es] To: mathgroup at smc.vnet.net Subject: [mg38247] [mg38195] Handling a list: Could you find a more elegant solution? 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/