Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

RE: Uniquely Subtracting Elements in a Flat List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29199] RE: [mg29182] Uniquely Subtracting Elements in a Flat List
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 2 Jun 2001 17:56:08 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Alan,

Here are two methods.

list = {a, b, c, d};

Drop[list - RotateLeft[list], -1]
{a - b, b - c, c - d}

Table[list[[i]] - list[[i + 1]], 
  {i, 1, Length[list] - 1}]
{a - b, b - c, c - d}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/ 




> From: Alan [mailto:kd7cyb at mac.com]
To: mathgroup at smc.vnet.net
> 
> I need help taking a flat list, such as {a,b,c,d} and generating another
> list by successively subtracting a-b, b-c, c-d, so that the resulting
> list would be {a-b,b-c,c-d}.
> 
> Thanks,
> Alan
> 
> 


  • Prev by Date: Re: Uniquely Subtracting Elements in a Flat List
  • Next by Date: repeating decimals
  • Previous by thread: Re: Uniquely Subtracting Elements in a Flat List
  • Next by thread: Re: Uniquely Subtracting Elements in a Flat List