MathGroup Archive 2004

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

Search the Archive

Re: Counting Runs

Take a look at the built in functions Split and Count.

On Nov 4, 2004, at 12:50 AM, Gregory Lypny wrote:

> Looking for an elegant way to count runs to numbers in a series.
> Suppose I have a list of ones and negative ones such as
> 	v={1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,1}.
> I'd like to create a function that counts the number of runs of 1s and
> -1s, which in this case is 3 and 2.
> 	Greg

  • Prev by Date: Re: How to force Mathematica to treat a number as positive and real?
  • Next by Date: Adding Vectors -- Newbie help please
  • Previous by thread: Counting Runs
  • Next by thread: Re: Counting Runs