Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: List difference using patterns and substitutions.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71334] Re: [mg71306] List difference using patterns and substitutions.
  • From: Mark Teagarden <Mark.Teagarden at utsa.edu>
  • Date: Wed, 15 Nov 2006 06:43:38 -0500 (EST)

Nacho,

Something like this?

a = {1,2,4,7,11,16};
out = Drop[a,1]-Drop[a,-1]

Mark

On 11/14/06 4:06 AM, "Nacho" <ncc1701zzz at gmail.com> wrote:

> Hello.
> 
> I'm trying to figure how can I build a difference list from another
> using only patterns and rule substitutions.
> 
> The idea is to get from a list, another, one element shorter, where
> each value is the substraction of two consecutive elements in the
> original list, that is, from {1,2,3,5,5} get {1,1,2,0}.
> 
> I've been thinking about it for a while, and I know several methods
> using a more traditional programming style (with For, for example), but
> I have no idea if it is possible to make it simple and fast with rule
> substitutions.
> 
> Any idea? 
> 
> Thanks in advance.
> 

-- 
Mark A. Teagarden, Ph.D.
University of Texas at San Antonio
Department of Biology
One UTSA Circle
San Antonio, TX 78249

Phone: 210.458.4746
FAX:   210.458.5658


  • Prev by Date: Re: Arithmetic Puzzle (so simple it's hard)
  • Next by Date: Re: Arithmetic Puzzle (so simple it's hard)
  • Previous by thread: Re: List difference using patterns and substitutions.
  • Next by thread: Re: List difference using patterns and substitutions.