MathGroup Archive 2001

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

Search the Archive

RE: Uniquely Subtracting Elements in a Flat List


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