MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Handling a list: Could you find a more elegant solution?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38289] Re: Handling a list: Could you find a more elegant solution?
  • From: Erich Mueller <emueller at mps.ohio-state.edu>
  • Date: Tue, 10 Dec 2002 04:18:40 -0500 (EST)
  • Organization: Ohio State University
  • References: <asn36u$40k$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

ListConvolve[{1/2, 1/2}, {a, b, c, d, e}]

or

Plus[##]/2 & @@@ Partition[{a, b, c, d, e}, 2, 1]



On Thu, 5 Dec 2002 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/
>
>
>
>



  • Prev by Date: RE: Handling a list: Could you find a more elegant solution?
  • Next by Date: Re: Handling a list: Could you find a more elegant solution?
  • Previous by thread: RE: Handling a list: Could you find a more elegant solution?
  • Next by thread: Re: Handling a list: Could you find a more elegant solution?