RE: Handling a list: Could you find a more elegant solution?
- To: mathgroup at smc.vnet.net
- Subject: [mg38243] RE: [mg38195] Handling a list: Could you find a more elegant solution?
- From: "SEPULVEDA,ARIEL (HP-PuertoRico,ex1)" <ariel.sepulveda at hp.com>
- Date: Tue, 10 Dec 2002 04:09:42 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Try this:
Apply[Plus,Partition[{a, b, c, d, e}, 2, 1],1]/2
Ariel Sepúlveda-Cuevas
Quality Department, HP-PRMO
PO Box 4048
Aguadilla, PR 00605
Tel (787)819-6057
Fax (787)819-6892
ariel_sepulveda at hp.com <mailto:ariel_sepulveda at hp.com>
-----Original Message-----
From: guillerm at usal.es [mailto:guillerm at usal.es]
To: mathgroup at smc.vnet.net
Subject: [mg38243] [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/