Re: number of switches

• To: mathgroup at smc.vnet.net
• Subject: [mg47506] Re: [mg47479] number of switches
• From: Tomas Garza <tgarza01 at prodigy.net.mx>
• Date: Thu, 15 Apr 2004 03:39:10 -0400 (EDT)
• References: <200404141116.HAA27212@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```It's hard to say which is the "easiest". This one does the job:

In[1]:=
digs = Table[Random[Integer, {0, 1}], {10}]
Out[1]=
{0, 1, 0, 1, 0, 1, 0, 0, 0, 1}

In[2]:=
Length[Split[digs]] - 1
Out[2]=
7

Tomas Garza
Mexico City
----- Original Message -----
From: "fake" <fake at fake.it>
To: mathgroup at smc.vnet.net
Subject: [mg47506] [mg47479] number of switches

> Consider the lists {1,1,0,1} and {1,1,0,0},{1,0,1,0,1}.
> The first sequence (1101) switches 2 times (#2digit~#3digit,
> #3digit~#4digit}, the second (1100) 1 time, the third 10101 4 times.
>
> I have the following problem.
> Consider a list of binary digits. Which is the easiest way to count the
> number of switches of the list (using Mathematica commands)?
>
>

```

• Prev by Date: Alternative to defining 'operator' function?
• Next by Date: Re: number of switches
• Previous by thread: Re: number of switches
• Next by thread: Re: number of switches